Removing Plugin from Autogenerated form - c#

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.

Related

winforms designer hand code bring to front

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);

How do i add another components on the MainWindow?

Struggling, I need a button to open up a window but below the MainWindow in C#. Like in a website you can open other pages but the master page layout doesn't change only the page you are viewing shows differently.
I need similar thing. I have components (tools i added from toolbox) on my MainWindow.xaml so for example if i click on a button i named new student, a tabbed-window where i can capture student details must appear but it must not be a separate windows it must appear within the mainwindow and seem like a one thing. Forgive for my English. I hope someone will understand me though, thanks in advance. I want to have components/functionality according a specific button click but constant Mainwindow, the one with "File" "Edit" "View" "Help".
There are a couple different solutions to you problem, but Visual Studio doesn't quite have something like the Master View option through ASP .NET with webforms.
Option One
Using TabControl. This option is the easiest solution to your problem. The GUI in Visual studio has support for adding components to each tab, which nothing else has. This is the closest component to something like multi-panels in Java, but it will still create the Tabs, which may not be what you are looking for.
Option Two
Using multiple Panels over one another. With this option, you can add multiple panels to your main window and layer each panel over one another. You can add a button or other control which will hide each panel and all of its contents. This is a great solution if you don't want tabs, but it can be frustrating to create in Visual Studio since you must move each panel away from another in order to add/remove/adjust the components on the underlying panel.
Of course there are still a few more controls you can use to produce the results you are looking for, but these are probably the most applicable solutions to your problem.

Which one is better generating controls(labels, textboxes, listview, buttons etc) on runtime or creating layout in c#?

I am working on my final year project, in my project i am using winform c#. My project is some sort of security system including hardware.
In my project I have a lots of controls like panels, textboxes, labels etc. Till now I am using layout and it is getting slower and slower (and flickering more and more) as I am adding more controls in it.
My question is that isn't it better to generate controls when required and destroy them when I don't need them? Will it save memory?
Assuming that you use the VS Windows Forms Designer, it will create the code for you which will be loaded at runtime. There will be no difference if you load the controls in Form.InitializeComponent (as the Designer does) or in any other place where you wrote it yourself. The only thing the designer does is it creates the Form.Designer.cs file for you while you design the form, and you can use those controls the same way you would use the controls you create at runtime yourself.
Loading a lot of controls on a single form is not a good practice. And it will get slower as you add more contols. You should probably consider redesigning the GUI.

How to make a tab's name editable in C#?

So I have a few tabs in the form, and i want it to work like that:
When you click on the tab's name, it becomes editable, and when i stop editing it remains with the new name.
How would i do that with C# and winforms?
You can dynamically create a text box and place it over the tab area to make the user think they are editing the tab directly. When the text box loses focus you can then put the typed in value into the tabs property.
I agree with Eric, regarding how you could do this with the standard TabControl. You could also provide a dialog to do the name change (a slight variation on Eric's suggestion).
However, I would also recommend that you consider rolling your own tabbed control. They're not difficult to create and by rolling your own, you will be able to put in the exact functionality you need in a robust way rather than trying to piece it together from existing components that may not play nicely together.
There's no standard Windows control that does this, so you'll either need to look for a third-party control with this functionality (iffy) or write your own control which draws the appropriate edit box on the tab, etc.

Is it good practice to stack multiple user controls on top of each other?

In my C# class, we use Visual Studio. My teacher says it is really not good practice to be stacking controls or panels on top of each other and hiding and showing them when needed. They say it should all be kept to separate forms. However, this puzzles me. I can understand that if you are in design mode, it is a little strange to see all these controls on top of each other, but you edit them all separately, so I don't see the issue. I think its really odd to be closing and opening forms like that and it looks a bit strange to the user.
Say you had an application in which you wanted to use multiple controls on top of each other. Say for example it was a login/register form and you didn't want to use a tab control, for whatever reason, and you wanted buttons in the menu strip to switch between the login or register user control, wouldn't it make sense to simply hide/show user controls?

Categories

Resources