Environment: VS 2012 Winforms
Is there any process to mass add or mass edit elements with a specific naming structure?
For example, I add a combo box, setup all the common properties, font, size etc with id of 'userInput_01', copy and paste it, and the pasted control ID should be 'userInput_02' and if I do it 28 more times, I should have userInput_01-userInput_28
One step further, copy a group of controls, a group box (gb_userinput_01), combobox (cb_userInput_01), button (btn_search_01), label (lbl_search_01) and have them all increment to _02, _03 etc when pasted.
I always manage this by hand, and with ~20 group boxes of various controls in my current project would have liked to have saved a chunk of manual control naming with some such ability. VS already auto increments a default name of controltype#, so the capability is there. From google, I saw a few results mentioning editing the designer files in a text editor, but that seems a crude hack to a solution that should exist in the designer.
Related
I change the text property of labels on a windows form. The form displays the correct new labels when displayed in the VS 2010 forms designer. I also change the color of the font.
When I run the program, the window displays the old text values instead of the new text values. The form displays the new font color on the labels.
There seems to be no occurrences of the old text value in the source code. Where is the old text value still hiding?
I clean the solution and rebuild it, but nothing changes.
A colleague observed that this is an artifact of converting projects from VS2005 to vs2008 to VS2010 and suggested a "brute force" corrective measure.
It actually worked.
1) Create a new blank form in the project.
2) In the original form, using the forms designer "Edit" menu, use the "select all" and "copy" actions. This copies all forms objects into the clipboard.
3) Paste the clipboard into the blank form.
4) Copy (most of) the program code from the old form into the new form, excluding anything generated by the forms designer.
5) Delete the old form from the project. Make changes as necessary to use the new form
Not very elegant, but good for meeting a deadline.
Thank you J.H!
Epilog:
"Brian" and "Blogbeard" both had the right direction in suggesting a hidden resource file.
Early in the execution of the code lay a method call to an obscure subsystem that no one knew anything about. That subsystem turned out to be a defunct language translation module which was supposed to translate all of the labels in a form from a native language to a target language.
It was configured to keep the original labels and their translations in a file outside the scope of the IDE. Changes in the form itself were completely ignored if the translator found the label name in its file.
Moving the form contents to another package effectively disabled the translator.
The elegant solution turned out to a three-line change that removed the method call to the translator. (it was no longer required in the application)
When I open a report from Dynamics NAV 2013 in Visual Web Developer 2010, every text box shows a field that looks like
<<Expr>>
Where << and >> are the french Guillemet characters. I find this rather difficult because I have to analyze the properties of each text box, if I am looking for a particular field.
For example in this picture, how do I know which field is the Customer Name, Phone Number or VAT Registration No?
Is there any way to configure Visual Web Developer to expand the Expression like it was in Visual Studio 2008 with NAV 6.0?
Preferably I would like to either see a label instead of the generic Expr or just the old Fields!Some_random_field.Value like it was in Visual Studio 2008.
Ah, another feature of NAV & RDLC :)
You'll find that the Expr text appears when an expression reaches a certain "complexity" -- e.g. from just a field;
=Fields!TotalText.Value
to
=(Fields!TotalText.Value)
The fields in the header are usually always Expr as the values are passed using GetData and SetData (and remain that way from NAV 2009 reports). While this limitation was somewhat removed in NAV 2013, you can only put static values in the header -- they won't change across pages which is useless for multiple SO's or Customers for example.
There isn't a way to show it in the properties box, however the quickest way seems to be to select the field, Right Click, "Expression".
I'd suggest giving the textbox a name other than TextBox to make it easier to identify fields (e.g. "SalesHeaderNo");
So after a bit of research I have found another solution. There is a View Element called the Document Outline [Ctrl+Alt+T] which shows a tree like structure of the whole report. When ever you click on an item in your report, the corresponding item in the Document Outline is selected and vice versa. This is quite useful to keep a better overview over your report and to quickly navigate between the different items.
The only annoying thing is that it also shows empty text boxes, so in a sparsely populated table, you will have a lot of textbox123 items in the outline. It doesn't seem there is a way to filter these out.
I downloaded a project off codeproject and was messing around with it (I am more an asp.net developer) when I noticed these overlay icons...the lock one on the label is really interesting as when I right click the control is unlocked yet all the properties are grayed out. When I add a new label I do not have that lock icon when I select it. What is this? Also what is the double boxes icon (the other 8 that are highlighted)?
The Winforms designer observes standard .NET accessibility keywords. The Modifiers keyword for a control is what counts here. That sets the access keyword for the member variable. The default for a C# project is private, for a VB.NET project it is Friend. VB.NET is more friendly about it.
That matters when you derive a form from a base form, Project + Add New Item, Windows Forms node, Inherited Form item template. The derived form will have the controls of the base form but they cannot be changed if their Modifiers property is Private. The designer makes it obvious by displaying the lock icon. And by displaying the properties of the control in gray text.
Normally this means that the controls are defined in the base control and so you cannot change them in the derived control (so they are all locked).
I am working on a windows form app like most development it is usually useful to see output. I am wondering what methods you use to see output in a windows form app.
PS. I am new to visual studio in general.
You can set some Labels around and display text on them:
Label.Text = "Some Text";
And DataGridView controls for information from tables, and for a better insight, you can set breakpoints in your code by clicking the far-left part of your code editing area. When the program reaches to that point it'll stop and you can hover your variables and objects for a better view of their insides...
Oh, and also VS has a "Locals" window when you run your project, that shows all the objects and variables being used and some information about them.
the user interface (a grid or other
controls on a form)
a report (like Crystal)
a file (.txt)
a database table updated
I need someone to point me in the right direction.
What would I need to do to collapse a region of text in a textbox?
I do not need to know how to allow a user to define regions, just how to collapse a region once you have the index and length of that region. I also want to, like visual studio does, leave a visual reminder of collapsed regions that you can click to expand them.
Visual Studio uses its own text editor control, not WPF's built in TextBox. Visual Studio's built-in text editor has many advanced features related to code editing but is not available separately from Visual Studio.
There are many open-source and componentware text editor controls available for WPF that include region collapsing. I suggest you download AvalonEdit or any of the text editor controls listed in this answer to see how it is done, and either reuse the control you downloaded or roll your own using similar techniques.
The technique most text editors use for region collapsing is to include a "outline hidden" flag in the data structure maintained for every line in addtion to an "is outline start" flag, an "outline end" pointer, and a "nesting level". By keeping these up to date and having the display templates honor them by drawing the proper icons/buttons and/or hiding the line, you can get the effect you need quite easily. Obviously this relies on your text editor's data structure tracking and displaying each line independently, which requires additional logic for selection, navigation, etc that is not included in WPF.