By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,213 Members | 1,517 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,213 IT Pros & Developers. It's quick & easy.

best way to proceed on Windows.Forms user interface?

P: n/a
Hello everyone,

I'm wondering if I could get some advice on the best way to build the user
interface depicted in this diagram:
http://www.senske.com/images/winforms_layout.jpg

The gray areas will be static throughout. However, I'd like the blue area
to change to a different interface depending on which of the buttons at left
is pressed. Should I design the interface for each of the buttons as a
separate custom user control, then swap the controls in and out depending on
which button is pressed?

Or, am I going about it entirely wrong and there's a better approach?

Thanks in advance for any insight.

Andre Ranieri

Mar 31 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Joe
Hello,

I would create a user control with a property like this:
enum ScreenMode {ContractInfo, Details, Leads, Services, AccountingAdj,
AccountingDefaults};

public ScreenMode ScreenMode
{
get
{
return // you current mode. probably stored in a variable
}
set
{
variable = value;
DoScreenModeChange();
}
}

Create a user control for each of the 6 screens you would need and just
switch them in the DoScreenModeChange() method.

HTH
-Joe
"Andre Ranieri" <An**********@discussions.microsoft.com> wrote in message
news:6C**********************************@microsof t.com...
Hello everyone,

I'm wondering if I could get some advice on the best way to build the user
interface depicted in this diagram:
http://www.senske.com/images/winforms_layout.jpg

The gray areas will be static throughout. However, I'd like the blue area
to change to a different interface depending on which of the buttons at
left
is pressed. Should I design the interface for each of the buttons as a
separate custom user control, then swap the controls in and out depending
on
which button is pressed?

Or, am I going about it entirely wrong and there's a better approach?

Thanks in advance for any insight.

Andre Ranieri

Mar 31 '06 #2

P: n/a
Joe,

Thanks immensely for your feedback. I'm fairly new to WinForm user
controls; I hope you'll bear with me while I ask a followup question or two:

Do I understand correctly that I can create one "master" user control (I
assume it woul be blank) which is placed on the form, then six other ones
for the six respective buttons?

In the DoScreenModeChange(); method, roughly how would I go about replacing
the contents of the master control (or whichever is displayed) with the new
one?

Thanks again,

Andre Ranieri
Mar 31 '06 #3

P: n/a
For your center area, find a control in the tool box called "Panel" add a
panel for each page you want in there, and put controls on that panel. make
sure they are "children" of that panel. To do that, just click the control
you want to add, and drag a box for it inside of the panel.

Anyways, here is a almost complete example:

using System;
using System.Collections;
using System.Windows.Forms;

namespace YourProject
{
public class PanelData
{
private static Hashtable m_Table = null;

public static void RegisterPanel(Panel panel, Button button)
{
if(m_Table == null)
m_Table = new Hashtable();
m_Table.Add(panel, button);
}

public static void HidePanels()
{
foreach(DictionaryEntry de in m_Table)
{
Panel panel = (Panel) de.Key;
panel.Hide();
}
}

public static void DisplayPanel(Button button)
{
HidePanels();
foreach(DictionaryEntry de in m_Table)
{
Button b = (Button) de.Value;
if(b == button)
{
Panel panel = (Panel) de.Key;
panel.Show();
break;
}
}
}

}
}
Now in your main form:

On form load:
PanelData.RegisterPanel(CustomersButton, CustomersPanel);
PanelData.RegisterPanel(HelpButton, HelpPanel);
//ETC
On a button click do this
PanelData.DisplayPanel(thisButtonNameHere);
"Andre Ranieri" wrote:
Joe,

Thanks immensely for your feedback. I'm fairly new to WinForm user
controls; I hope you'll bear with me while I ask a followup question or two:

Do I understand correctly that I can create one "master" user control (I
assume it woul be blank) which is placed on the form, then six other ones
for the six respective buttons?

In the DoScreenModeChange(); method, roughly how would I go about replacing
the contents of the master control (or whichever is displayed) with the new
one?

Thanks again,

Andre Ranieri

Mar 31 '06 #4

P: n/a
Maybe you also could give a look at composite ui application block...

For your center area, find a control in the tool box called "Panel"
add a panel for each page you want in there, and put controls on that
panel. make sure they are "children" of that panel. To do that, just
click the control you want to add, and drag a box for it inside of the
panel.

Anyways, here is a almost complete example:

using System;
using System.Collections;
using System.Windows.Forms;
namespace YourProject
{
public class PanelData
{
private static Hashtable m_Table = null;
public static void RegisterPanel(Panel panel, Button button)
{
if(m_Table == null)
m_Table = new Hashtable();
m_Table.Add(panel, button);
}
public static void HidePanels()
{
foreach(DictionaryEntry de in m_Table)
{
Panel panel = (Panel) de.Key;
panel.Hide();
}
}
public static void DisplayPanel(Button button)
{
HidePanels();
foreach(DictionaryEntry de in m_Table)
{
Button b = (Button) de.Value;
if(b == button)
{
Panel panel = (Panel) de.Key;
panel.Show();
break;
}
}
}
}
}
Now in your main form:

On form load:
PanelData.RegisterPanel(CustomersButton, CustomersPanel);
PanelData.RegisterPanel(HelpButton, HelpPanel);
//ETC
On a button click do this
PanelData.DisplayPanel(thisButtonNameHere);
"Andre Ranieri" wrote:
Joe,

Thanks immensely for your feedback. I'm fairly new to WinForm user
controls; I hope you'll bear with me while I ask a followup question
or two:

Do I understand correctly that I can create one "master" user control
(I assume it woul be blank) which is placed on the form, then six
other ones for the six respective buttons?

In the DoScreenModeChange(); method, roughly how would I go about
replacing the contents of the master control (or whichever is
displayed) with the new one?

Thanks again,

Andre Ranieri

Mar 31 '06 #5

P: n/a
Thanks for your help. I think this will work fine.

I ended up using user controls instead of panels for the solution because
each element will have a fair amount of back-end code for data binding, etc,
and I didn't want all the code packed up in one form class.

Andre Ranieri
Apr 1 '06 #6

P: n/a
User controls are also superior because you can design them separately,
in their own design spaces, then merely place them on the final form.
Designing all six panels in the same form is difficult. (I know: I've
tried it. :-( )

Apr 1 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.