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
Related
I'm working on an old project that supports Windows Forms.
This project contains some ResourceManager for the support of a few localizations. The idea is that you call ResourceManager["SomeResource"] instead of Resource.SomeResource and it returns you a localized string.
And these localized strings are used in the code of the initialization of the form. For example, you have Form1, and in Form1.Design.cs there is some code like this:
Label label1 = new Label();
label1.Text = ResourceManager["SomeResource"];
So the label will be created with an already localized string in the Text.
And we need to add the functionality of changing the UI language without reloading the Form.
We can just set the every Text property of every controls again. But it's a lot of code, the form contains a lot of controls.
We can call the Form.InitializeComponents(), this method will recreate all controls with new localized strings, but in some cases, it works slowly because it reloads some big data again.
Is there some other way to refresh all UI controls and get the new localized strings? Do Windows Forms support some mechanism like Binding in the WPF to create the "connection" between the Text properties and localized resources?
I think that you can achieve this by use of Invalidate() either on the form itself or on a container control that your other controls may be encompassed by.
I'm developing in Winforms with a .NET 4 profile in Visual Studio 2010 at Windows' 100% scaling (96dpi) on Windows 10.
As per the advice from this highly rated answer, I set dpiAware to true in the app.manifest file, set the AutoScaleMode of the main Form to Font, and since I have splitContainers in the Form, but they very unfortunately don't have an AutoScaleMode property in the Wysiwyg Designer, I also have to add these lines to the Designer.cs file:
*.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
*.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
This ensures that if the user happens to use Windows in 125%, 150% or even other scaling modes, then the GUI will resize properly, without some components being too small or too big.
Unfortunately, as per the advice of the aforementioned link: "Only the controls in the Controls lists when ResumeLayout at the end of InitializeComponent is called will be auto-scaled", which means I need to put the above two lines in the Designer.cs file. I can't simply put them later in the Form Load event.
Unfortunately, this means that whenever I update or move about a widget/button/label in the Wysiwyg editor, the Designer.cs file is automatically recreated, and I lose my two lines of code above. So I have to keep remembering to put them back in every time I update the GUI in the Wysiwyg editor.
The link also supplies a potential solution to avoid this ugliness by partially avoiding the use of the Wysiwyg editor, and instead creating the splitContainers programmatically in the Load event. I quote: "if you dynamically add controls, then you need to SuspendLayout(); AutoScaleDimensions = new SizeF(6F, 13F); AutoScaleMode = AutoScaleMode.Font; ResumeLayout(); on that control before you add it in".
The problem there is that I have a ton of splitContainer code to move over (such as objects being added to the splitContainers), and it will ruin the look of the Wysiwyg editor (I want to see my splitContainers thank-you-very-much as they are a crucial part of the GUI and have many elements/widgets inside that I also want to see when designing!).
My question is if I can get the best of both worlds: Keep the look of the splitContainers and contents in the Wysiwyg editor, while keeping the functionality of proper scaling by utilizing the two lines of code above (*.AutoScaleMode = ... and *.AutoScaleDimensions = ...) which seemingly must be in the Designer.cs file before *.ResumeLayout() is called.
I am building a GUI program that allows users to choose between a few software profiles for them to get written to their USB drive. I have chosen GTK+ 3.0 in C, and my supervisor is aware of my chosen method, so I am not changing it.
What I am trying to do is really quite simple but I'm still having trouble finding a comprehensive answer.
I want to be able to allow the user to select a (text) entry in the combo box and have the corresponding description show up in the frame/textview. The description in the textview should change properly to be the description for that combo box entry (the one selected).
My UI is mostly contained within a Glade file. Currently, the UI is functional but changing between combo box entries does nothing to the textview.
EDIT: I removed the posting of my code because it's too long and maybe it was throwing people off. Apologies. I can post things at request. Thanks.
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)
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.