winforms designer hand code bring to front - c#

I'm converting some VB6 forms to C# and have created an utility which generates C# designer files from the VB6 source files. It's going well, but I've ran into some trouble with ordering.
I have an option button and an updown beside each other and the right side of the option button is slightly overlapping the updown. I tried resizing the option button, but no usable size seems to leave the caption visible.
I've considered changing the option button to have a transparent background, but unfortunately the solution isn't viable for all of my forms.
However, what I think would definitely work is bringing the updown to the front or sending the option button to the back, but I can't figure out how to do this from within the designer code only.
How can I bring controls to the front or send them to the back from the designer code? If anyone has a different solution for having the caption visible I'm open for suggestions. It must be done from within the designer code only, as that is what my tool generates.

The order in which controls are added to their parent determines the initial Z-order. The control added first will be in front of controls added later:
this.Controls.Add(updownButton);
this.Controls.Add(optionButton);

Related

Removing Plugin from Autogenerated form

I have a WinForm project that I used DevExpress buttons and labels to create. It turns out that not all devs have a license for DevExpress, so I need to change all references to it to the standard WinForm buttons and labels. The problem is that this is a complex form with over fifty elements on numerous (DevExpress) tabs.
It would be nice an easy to go in and change the DevExpress to the correct Windows buttons, labels and tabs except editing auto generated code just gives VS something to change back to what it wants. However, it sounded like changing Form.Designer.cs may be possible from one of the answers here.
My question is, can I make permanent changes to Form.Designer.cs, or will they be overwritten at some point by VS. If they will be overwritten, is there a simple way to swap out buttons and labels, if I want everything to stay the same except using the WinForm button rather than DevExpress button. Replacing them could work, but I have the tab controls to worry about.
Is my best bet to start a new WinForm, copy the code I wrote, and recreate the design?
Thanks for any suggestions.

How to Show the Form's Own Icon on a Floating Window using DockPanel and its Extender?

With the Weifen Luo DockPanel component, one can add to their .net project the ability to dock forms within other forms. The component is very well done.
Now, I see from this page at the project forum at github (where this component is now hosted), that it is possible, through the use of this dock.extender to allow the floating windows to have a normal winform look, that is, sizeable with regular Windows title bar, maximize box, minimize box, etc (see here, too). This also allows for the form's icon to show.
My problem is, and hence my question, is that the icon I assign in the form's properties will show in the designer, but one it runs in debug as a float-panel, a generic form icons appears in its place.
Now, I tried assigning the icon through code (both in the form's own code, and in the main application code too, where the form is called) rather than through properties, and that didn't work either.
So how do I get my own custom icon to show as the form's icon when the form is floated, and the extender is used? I am using the main docking panel in DockingWindow mode.
[EDIT]
I think this is a hard question! It's been 2 days and I've not gotten any answers!
This requires a change to the the FloatWindow class itself to set and update the Icon property internally as the content changes.
I have just checked the change in and it will be included in the 2.7 release of the library.
https://github.com/dockpanelsuite/dockpanelsuite/issues/35

Control no longer gaining focus after putting it in a splitcontainer

I have a forms app and when it starts up I would like it to give focus to a particular text box. While I was initially developing I just whacked all the controls straight on the form and the focus command worked fine.
The app is near ready and I put some splitcontainers on the form just to hold the controls in neatly defined areas using their Dock properties. Now a completely different read only control gets focus on startup and the app seems to ignore my command that the focus should go to this one textbox. Does any one know why this might be?
You can try this :
splitContainer1.Focus();
splitContainer1.ActiveControl = textBox1;
If it doesn't works please post your focus code here.
Sorry because i didn't write a comment but i don't have the privilege yet.

How to temporarily disable Visual studio auto generated events?

All,
I have finished the GUI design phase... Now I've started to add meaningful names to all the controls in my application. Visual Studio is driving me nuts auto generating the events each time I click on the control to change its name (ok so it only happens when I mess up and double click... but still annoying).
Is there a way to temporarily disable this feature? I still want it because it is a great short cut when I'm coding.
Thanks!
You can't disable double clicking AFAIK but you can open document outline (Menu View > Other Windows > Document Outline), and rename the controls via F2 in this window. It'll be much faster and will help see easily the visual tree if your form is complex.
afaik there is not. Just be careful with your clicking and if you do mess up CTRL+Z CTRL+Z is your friend :)
If you can recognize which controls are which in code, you could open the .Designer.cs files and rename the controls there with the refactoring tool (right click the control name, Refactor, Rename).
It may or may not be straightforward to recognize which controls are which given that you have used generic names so far, but at least it's an option. Personally, I avoid that situation by immediately assigning meaningful names.
It's not just renaming controls, it's resizing them by dragging that is a bigger problem. CTRL+Z works to remove the auto-generated code but simultaneously undoes the resizing of the control. Very annoying.

C#: Move Controls From Form to tabPage in VS Form Designer

I decided to change a utility I'm working on to use a tabpage. When I tried to drag various controls from the form to a tab page on top of the form, it made copies of the control, giving it a different name. It's easy enough to just remake the form on top of the tab or just edit the source code in the designer to have everything be added to the tab instead (and this is what I did, which worked), but it seems like there would probably be a better way to do this via the gui.
The correct tool for this is the Document Outline (CTRL+W, U). Simply drag your set of controls in the outline so that they are under the tab page. Voila.
The document outline dramatically simplifies these types of operations, especially when you are dealing with complex layouts.
Have you tried cut and paste. That usually works for me.
Your control key is stuck. Do not press control key when dragging controls.
I drag controls from form control to tab page controls all the time no problem. Answer #1 is totally correct.
You can use the Document Outline window and move the controls to the tab page one by one by dragging tree nodes.
The hardest problem is retaining control locations on the tab page.

Categories

Resources