I created a GUI in C# which should look like this:
On Main Screen there are two Buttons, When Button1
is clicked I don't want to open a new form using form2.show();
but while staying in the same form I want to change display.
I did this using hiding GUI elements and showing the other elements as required.
It works fine as I wanted but in the designer View of Form1
I had to create messy GUI.
My question is that is it good programming practice or not? If not then what is the best or recommended way to achieve this.
thanks
You might want to consider a 'Tabless' tab control, I tend to use them for a lot of my work these days as it's easy and quick to build an interface using the win-forms designer with them.
class TablessTabControl : TabControl
{
protected override void WndProc(ref Message m)
{
// Hide tabs by trapping the TCM_ADJUSTRECT message
if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1;
else base.WndProc(ref m);
}
}
This will extend the tab control and hide the tabs along the top, you can then change tab programmatically by using code similar to the following:
tablessTabControl.SelectTab("tabName");
This isn't my original work, I found it floating around the web a while back and can't remember where I saw it. Anyway I hope this helps!
how about using TabControl, you get all the 'views' you want without messy
visible = true/false
shizzle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With