I have a lot of forms in my app, and they all need to be translated. Solution is pretty simple with resx files. But also I need to translate messagebox texts, and texts that are displayed in buttons accoroding to current action. I have tried to add string in my *.de.resx file in VS2010, but it disappears after switching form language.
Then I found a solution to store text in hidden labels, but this looks very ugly. Is there a way to add strings to resx without hidden labels?
You probably need to just add a standalone resx to your project (Add, New Item, Resources File). A form resx isn't a safe place to store your non-ui data, as it's autogenerated, and, as you've found, it can delete your alterations when it's regenerated.
Related
In our current application there is a new requirement of our client.As they told that they need n numbers of forms at different stages of their business and those are changing time to time. Even a new forms can be added. Their requirement is once the product is delivered to them they will not come back to us again and again for each change and will create those form by their own.
Simply they want a user interface where they can create the form by drag and drop manner.
What they want :
In our application there will be a form building section where a non technical person can be able to create a form.
Mapping the controls with existing data of their existing database so that the form is populated with the corresponding data ( data will be inserted into the database using another user interface).
Once the data is populated they will take the print out of the filled up form and will proceed as per their business flow.
As they introduce new form time to time we can't provide any predefined template to them and they are not agree to design the form in HTML.
Is there any way of doing this in Asp.Net MVC (without using any CMS ).
there are a number of asp.net forms builders. And I been wanting to build my own for years. (you store the control, the location etc in a database, or even as xml, and then on page load, read the xml, and crank out the controls and layout into the page. We all built these for desktop, and you can do the same for the web.
The open source evolutility project has a FANTASTIC system for this, but it does NOT include the GUI part. But, it would be a good start. You would have to build the GUI part, but the rendering part, and save of the forms layout is all done for you. So, your forms builder would offer a set of controls to drop and move around in the form. When you save, you would have a corresponding "xml" markup bit that you save to the one "forms layout" file. On forms load, you read that xml file and produce the form (that's the part evolutility does for you). So, you need the part that has each control in a tool box (along with the xml for that control). you drop control into form, and add the xml to the "form layout in xml".
As I stated, evolutility has all the parts to render forms and layout and place controls on the final finished form for display - it just don't have a GUI for doing this part.
You can look at the project here:
http://evolutility.com/
there are others. But, it really depends on how complex of a form builder or content builder you wish to make.
But, a xml, or json based layout and definition of the controls placed on a page is a good start. You could store such "layout" information in a database. Heck have a classic master to child table, and thus save each control in evolutiity format, and simple append then all together, and then have evolutility render that xml into a working form for you.
I don't know of a open source project that combines both the "layout" and "define" of the controls AND ALSO has a GUI to build the forms. But, to be fair, the hard part (how to layout, and how to have each control defined in some json (or xml) is done for you.
I have a VS Solution in that my project contains something around 160 Forms. Now I want to get the Control's text property from all the forms.
Why I want to do is my application is in English Language. My client asked me to convert the whole software into other languages also. Now he wants me to provide him list of all menu and other controls in a Excel or XML sheet from where he will translate everything.
SO is there any mechanism available which can read all of my forms and its control and save text/caption of every item in a external file or may be in any medium.
Is it possible. Looking for fellow support. Regards.
ADD1:
Like I have a MDI form and its designer contains this.mnu_recycle.Text = "Recycle";
Likeways we have n number of .Text items. I just want a list of all of them.
Create some code that creates an instance of each form then loops through all the controls getting the text and name of the control. Write the info (Form name, control name, control text) to a csv file or generate a resource file which can be translated. You can then write a small app to change the form code files to use resource files.
Programmatically creating a resource file
http://msdn.microsoft.com/en-us/library/gg418542.aspx
Resource files will make your application be easier to translate to other languages take a look at these
C#: How to bind the text of a winforms button to a resource
What would be the easiest way to generate new localized resource files?
How to load C# winform strings from resource file without rebuild
I try to duplicate a form in my Designer with all the elements on it, that i have not to do the huge Job again of designing the full form again. I need only a few little changes on this form copy to do, so i do not want to design the same again from new.
If i click on the form "copy" and then do "paste" on my Project the full Project is destroyed forever and a lot of error Messages Pop up about the form copy. I had to throw my Project afterwards since there's no undo of that action possible. Since this was a huge loss of work I decided to ask the question:
How do I valid copy/duplicate an existing form in the designer without errors afterwards appearing?
You should duplicate the form file, then change the class name in the copy in both the .cs and the .Designer.cs files.
I'm trying to design my C# winform application with a very generalized function to automatically go through all of the form elements and save their states/values in a text file so that I can load it later. I want it to be very generalized so that it'll be a cinch to reuse this code in future projects, as it wouldn't be heavily tied down to the specifics.
The form elements I want to save are text boxes, combo boxes, data grid views, list boxes and that's about it. I want to save their values and everything about them.
One way that I was going about it was to go through every possible form element and then detect eachs type, and then create the corresponding c# code to re-create its value ('tboxmine.value="blue elephant"'), and then writing the code to a file, so that I could load the code from the file and execute it using the CSCcompiler. My code so far doesn't seem to be working correctly and I'm having my doubts that this compiler is actually running the code inside my application (I think it's possibly creating a new thread?), and it just seems like there's probably a far more straightforward relatively standard way of doing this.
This seems a bit like the reverse "best practice" approach. If you dont't know about databinding I suggest you look into that.
Basically you create classes to represent your data and use databinding to associate controls with your objects. The controls will automatically show the right value and allow the user to change it. If the user has changed the value, your object gets automatically updated.
To save the data, you would use some kind of serialization to store your objects in a file. When loading, you let the Serializer rebuilt your class structure and (best case) you are good to go.
This is not exactly what you asked for, but I think it is something you could use well ;-)
N.B.: Not the complete state of the control is saved. e.g. in a Textbox your text would be saved but the BackColor won't.
To get you started look into this tutorial: http://www.codeproject.com/Articles/24656/A-Detailed-Data-Binding-Tutorial
I have a form in my existing project.
My current task is to make a duplicate of an existing form and change few things on the new form. Making a copy of the form cs files would not do since the existing contents themselves refer to file information.
Simply put, I am trying to crate a form name MyNewForm, which will be a direct duplicate of MyCurrentForm without causing any naming conflict that may arise in mere copy pasting of code content.
What is the fastest way I can achieve this?
Copy the form in visual studio solution explorer. Rename it. And change the class name manually both in .cs and .Designer.cs files. Do not use VS refactoring feature as it blows away references to the original class.
To duplicate a form (in the same project):
Right click on the source form --> Copy
Right click on the destination folder/project --> Paste
Right click on the new form --> Rename
Change manually the class name in .cs
Change manually the constructor name in .cs
Change manually the class name in .Designer.cs
Enjoy!
Why do you need to make a duplication of the form? Try to find some refactoring that can help you, e.g. create some base form and extract common logic there.
Every time you make a duplication kitten dies!
You can just add a new blank form and then select all items on the original aform and paste them onto the new form. This will not copy the code behind though. But that can also be solved with copy paste.
This will not cause any renaming conflicts.