473,587 Members | 2,548 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# GUI

Hi,

I am developing an app which i want to have same style of GUI as the .NET
Configuarion tool. i.e menus at top,rest of dialog dialog split into two with
a tree like structure on the left and when item is selected on it, its
contents are displayed on the right hand side.

I'm not sure how to achieve this( maybe using splitter control with treeview)

I'd appreciate any suggestions that could help me do the above

Thanks In Advance
Macca
Nov 17 '05 #1
5 1874
Add a TreeView to the Form and set it's Dock property to DockStyle.Left.
Add a panel or a single control that will display the properties such as a DataGrid to the Form and set it's Dock property to
DockStyle.Fill.

The splitter can be used if you want the TreeView to be resizable at runtime.

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussi ons.microsoft.c om> wrote in message news:A2******** *************** ***********@mic rosoft.com...
Hi,

I am developing an app which i want to have same style of GUI as the .NET
Configuarion tool. i.e menus at top,rest of dialog dialog split into two with
a tree like structure on the left and when item is selected on it, its
contents are displayed on the right hand side.

I'm not sure how to achieve this( maybe using splitter control with treeview)

I'd appreciate any suggestions that could help me do the above

Thanks In Advance
Macca

Nov 17 '05 #2
Hi Dave,

Thanks for the info.

How do i syncronise the treeview and panel?

i.e when i select an option on the treeview the panel should change to the
appropriate view.

Cheers
Macca
"Dave" wrote:
Add a TreeView to the Form and set it's Dock property to DockStyle.Left.
Add a panel or a single control that will display the properties such as a DataGrid to the Form and set it's Dock property to
DockStyle.Fill.

The splitter can be used if you want the TreeView to be resizable at runtime.

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussi ons.microsoft.c om> wrote in message news:A2******** *************** ***********@mic rosoft.com...
Hi,

I am developing an app which i want to have same style of GUI as the .NET
Configuarion tool. i.e menus at top,rest of dialog dialog split into two with
a tree like structure on the left and when item is selected on it, its
contents are displayed on the right hand side.

I'm not sure how to achieve this( maybe using splitter control with treeview)

I'd appreciate any suggestions that could help me do the above

Thanks In Advance
Macca


Nov 17 '05 #3
Handle the AfterSelect event of the tree view and perform any necessary operations on the panel in code.

// Initialize the tree view (or let the designer do this for you):

public Form1()
{
TreeView tree = new TreeView();
tree.Dock = DockStyle.Left;

// Add a handler for the AfterSelect event:
tree.AfterSelec t+= new TreeViewEventHa ndler ( TreeNodeSelecte d );

Controls.Add(tr ee);

Panel view = new Panel();
view.Dock = DockStyle.Fill( );
Controls.Add(vi ew);
}
// Handle the AfterSelect event:

private string currentViewType = null;

private void TreeNodeSelecte d(object sender, TreeViewEventAr gs e)
{
/*
I'm assuming that viewType1 and viewType2 are instances of UserControl-derived classes.
If you have a view for each node type, you can create a UserControl for each view that may be displayed.

I also used a global-scope variable named, "currentViewTyp e" that keeps track of the currently displayed view.
When you add Node objects to the "tree", make sure to set the "Node.Tag" property to the appropriate view type
name to be displayed.

For simplicity I used currentViewType as a string although an enumeration would make more sense if the node
types cannot be changed at runtime.

If you need more info for each Node other than just it's view type, you can set the Tag to a custom structure or class
that holds more information about the Node.
*/

if (e.Node.Tag == currentViewType )
return;

currentViewType = e.Node.Tag as string;

// remove the current view
// here would be a good place to save any changes before the next line of code
view.Controls.C lear();

switch (currentViewTyp e)
{
case "Type1":
view.Controls.A dd(viewType1);
break;
case "Type2":
view.Controls.A dd(viewType2);
break;
}
}

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussi ons.microsoft.c om> wrote in message news:9E******** *************** ***********@mic rosoft.com...
Hi Dave,

Thanks for the info.

How do i syncronise the treeview and panel?

i.e when i select an option on the treeview the panel should change to the
appropriate view.

Cheers
Macca
"Dave" wrote:
Add a TreeView to the Form and set it's Dock property to DockStyle.Left.
Add a panel or a single control that will display the properties such as a DataGrid to the Form and set it's Dock property to
DockStyle.Fill.

The splitter can be used if you want the TreeView to be resizable at runtime.

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussi ons.microsoft.c om> wrote in message news:A2******** *************** ***********@mic rosoft.com...
> Hi,
>
> I am developing an app which i want to have same style of GUI as the .NET
> Configuarion tool. i.e menus at top,rest of dialog dialog split into two with
> a tree like structure on the left and when item is selected on it, its
> contents are displayed on the right hand side.
>
> I'm not sure how to achieve this( maybe using splitter control with treeview)
>
> I'd appreciate any suggestions that could help me do the above
>
> Thanks In Advance
> Macca


Nov 17 '05 #4
Hi Dave,

Thanks for the info. It has been very helpful. I just have a couple of
questions for you.

Each of the nodes in my treeview will give the user a different "view" in
the panel or whatever is best to display it.

Each view will consist of a number of user controls on it, such as combo
box, list views.push buttons etc.

One view will ask the user to input information into such controls which
when the user selects the appropriate button will query a database and then
produce a crystal report.(i have this database/crystal report functionality
in another app which i will use for this view).

Another view will contain text with link labels that will bring up another
page of text or a dialog.

What i would like to be able to do is design these "views" at design time
through editor and not programatically if possible.

Then i assume as i select a node in the treeview i could invoke the
appropriate view as you have showed me.

The example you showed me i assume have the "views" designed programmically.

Is what i am asking possible? Will i need to do something a bit different
from what you initially suggessted in using a panel control for the views?

Thanks In Advance
Macca
"Dave" wrote:
Handle the AfterSelect event of the tree view and perform any necessary operations on the panel in code.

// Initialize the tree view (or let the designer do this for you):

public Form1()
{
TreeView tree = new TreeView();
tree.Dock = DockStyle.Left;

// Add a handler for the AfterSelect event:
tree.AfterSelec t+= new TreeViewEventHa ndler ( TreeNodeSelecte d );

Controls.Add(tr ee);

Panel view = new Panel();
view.Dock = DockStyle.Fill( );
Controls.Add(vi ew);
}
// Handle the AfterSelect event:

private string currentViewType = null;

private void TreeNodeSelecte d(object sender, TreeViewEventAr gs e)
{
/*
I'm assuming that viewType1 and viewType2 are instances of UserControl-derived classes.
If you have a view for each node type, you can create a UserControl for each view that may be displayed.

I also used a global-scope variable named, "currentViewTyp e" that keeps track of the currently displayed view.
When you add Node objects to the "tree", make sure to set the "Node.Tag" property to the appropriate view type
name to be displayed.

For simplicity I used currentViewType as a string although an enumeration would make more sense if the node
types cannot be changed at runtime.

If you need more info for each Node other than just it's view type, you can set the Tag to a custom structure or class
that holds more information about the Node.
*/

if (e.Node.Tag == currentViewType )
return;

currentViewType = e.Node.Tag as string;

// remove the current view
// here would be a good place to save any changes before the next line of code
view.Controls.C lear();

switch (currentViewTyp e)
{
case "Type1":
view.Controls.A dd(viewType1);
break;
case "Type2":
view.Controls.A dd(viewType2);
break;
}
}

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussi ons.microsoft.c om> wrote in message news:9E******** *************** ***********@mic rosoft.com...
Hi Dave,

Thanks for the info.

How do i syncronise the treeview and panel?

i.e when i select an option on the treeview the panel should change to the
appropriate view.

Cheers
Macca
"Dave" wrote:
Add a TreeView to the Form and set it's Dock property to DockStyle.Left.
Add a panel or a single control that will display the properties such as a DataGrid to the Form and set it's Dock property to
DockStyle.Fill.

The splitter can be used if you want the TreeView to be resizable at runtime.

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussi ons.microsoft.c om> wrote in message news:A2******** *************** ***********@mic rosoft.com...
> Hi,
>
> I am developing an app which i want to have same style of GUI as the .NET
> Configuarion tool. i.e menus at top,rest of dialog dialog split into two with
> a tree like structure on the left and when item is selected on it, its
> contents are displayed on the right hand side.
>
> I'm not sure how to achieve this( maybe using splitter control with treeview)
>
> I'd appreciate any suggestions that could help me do the above
>
> Thanks In Advance
> Macca


Nov 17 '05 #5
Hi Macca,

See inline comments below.
What i would like to be able to do is design these "views" at design time
through editor and not programatically if possible.
You can design each view as a control that derives from UserControl (this can be added using VS.NET as "Add New Item...", "User
Control" and will provide you with a designer).
Is what i am asking possible? Will i need to do something a bit different
from what you initially suggessted in using a panel control for the views?
In my example following this comment

// Initialize the tree view (or let the designer do this for you):
Panel view = new Panel();
view.Dock = DockStyle.Fill( );
Controls.Add(vi ew);


the view that is being added was not intended to hold view-specific controls but instead to be the container for "view" controls.
It's the variable name that threw you off. It should be called, "viewContainer" . I mentioned UserControl in the large comment
found in the "TreeNodeSelect ed" method example and I did intend for you to make UserControl's as your views. The reason for the
panel is simply for ease of docking or if you wanted to control visual aspects of the view area such as a border. When a view is to
be shown (UserControl), it must be added to Controls collection of the "view" variable and not the parent Form. Changing the name
to viewContainer as I mentioned might make things clearer.
Then i assume as i select a node in the treeview i could invoke the
appropriate view as you have showed me.
This requires code, but yes my example should work nicely for you. Ensure that the "TreeNodeSelect ed" method I gave in my original
example is a handler for your TreeView's "TreeNodeSelect ed" event.

The purpose of setting the Tag property of each node is to associate the node with a view. This may be overkill for your needs but
I used it in the example to be dynamic. If you want to simplify the "TreeNodeSelect ed" to associate nodes with specific text to
specific views, the modified code could be changed to look like this:

private void TreeNodeSelecte d(object sender, TreeViewEventAr gs e)
{
if (e.Node.Text == currentViewType )
return;

currentViewType = e.Node.Text;

// remove the current view
// here would be a good place to save any changes before the next line of code
view.Controls.C lear();

switch (currentViewTyp e)
{
case "Type1":
view.Controls.A dd(viewType1); // viewType1 is a referene to a UserControl instance that is one of your "Views"
break;
case "Type2":
view.Controls.A dd(viewType2); // viewType2 is a referene to a UserControl instance that is one of your "Views"
break;
}
}
I hope that clears up some of the confusion with my code.

GL

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussi ons.microsoft.c om> wrote in message news:FE******** *************** ***********@mic rosoft.com... Hi Dave,

Thanks for the info. It has been very helpful. I just have a couple of
questions for you.

Each of the nodes in my treeview will give the user a different "view" in
the panel or whatever is best to display it.

Each view will consist of a number of user controls on it, such as combo
box, list views.push buttons etc.

One view will ask the user to input information into such controls which
when the user selects the appropriate button will query a database and then
produce a crystal report.(i have this database/crystal report functionality
in another app which i will use for this view).

Another view will contain text with link labels that will bring up another
page of text or a dialog.

What i would like to be able to do is design these "views" at design time
through editor and not programatically if possible.

Then i assume as i select a node in the treeview i could invoke the
appropriate view as you have showed me.

The example you showed me i assume have the "views" designed programmically.

Is what i am asking possible? Will i need to do something a bit different
from what you initially suggessted in using a panel control for the views?

Thanks In Advance
Macca
"Dave" wrote:
Handle the AfterSelect event of the tree view and perform any necessary operations on the panel in code.

// Initialize the tree view (or let the designer do this for you):

public Form1()
{
TreeView tree = new TreeView();
tree.Dock = DockStyle.Left;

// Add a handler for the AfterSelect event:
tree.AfterSelec t+= new TreeViewEventHa ndler ( TreeNodeSelecte d );

Controls.Add(tr ee);

Panel view = new Panel();
view.Dock = DockStyle.Fill( );
Controls.Add(vi ew);
}
// Handle the AfterSelect event:

private string currentViewType = null;

private void TreeNodeSelecte d(object sender, TreeViewEventAr gs e)
{
/*
I'm assuming that viewType1 and viewType2 are instances of UserControl-derived classes.
If you have a view for each node type, you can create a UserControl for each view that may be displayed.

I also used a global-scope variable named, "currentViewTyp e" that keeps track of the currently displayed view.
When you add Node objects to the "tree", make sure to set the "Node.Tag" property to the appropriate view type
name to be displayed.

For simplicity I used currentViewType as a string although an enumeration would make more sense if the node
types cannot be changed at runtime.

If you need more info for each Node other than just it's view type, you can set the Tag to a custom structure or class
that holds more information about the Node.
*/

if (e.Node.Tag == currentViewType )
return;

currentViewType = e.Node.Tag as string;

// remove the current view
// here would be a good place to save any changes before the next line of code
view.Controls.C lear();

switch (currentViewTyp e)
{
case "Type1":
view.Controls.A dd(viewType1);
break;
case "Type2":
view.Controls.A dd(viewType2);
break;
}
}

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussi ons.microsoft.c om> wrote in message news:9E******** *************** ***********@mic rosoft.com...
> Hi Dave,
>
> Thanks for the info.
>
> How do i syncronise the treeview and panel?
>
> i.e when i select an option on the treeview the panel should change to the
> appropriate view.
>
> Cheers
> Macca
>
>
> "Dave" wrote:
>
>> Add a TreeView to the Form and set it's Dock property to DockStyle.Left.
>> Add a panel or a single control that will display the properties such as a DataGrid to the Form and set it's Dock property to
>> DockStyle.Fill.
>>
>> The splitter can be used if you want the TreeView to be resizable at runtime.
>>
>> --
>> Dave Sexton
>> dave@www..jwaon line..com
>> -----------------------------------------------------------------------
>> "Macca" <Ma***@discussi ons.microsoft.c om> wrote in message news:A2******** *************** ***********@mic rosoft.com...
>> > Hi,
>> >
>> > I am developing an app which i want to have same style of GUI as the .NET
>> > Configuarion tool. i.e menus at top,rest of dialog dialog split into two with
>> > a tree like structure on the left and when item is selected on it, its
>> > contents are displayed on the right hand side.
>> >
>> > I'm not sure how to achieve this( maybe using splitter control with treeview)
>> >
>> > I'd appreciate any suggestions that could help me do the above
>> >
>> > Thanks In Advance
>> > Macca
>>
>>
>>


Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11195
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL) on the server because of that. Our site will have an SSL certificate next week, so I would like to use AIM instead of SIM, however, I don't know how...
2
5792
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues to execute the code until the browser send his reply to the header instruction. So an exit(); after each redirection won't hurt at all
3
22987
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which field is completed.
0
8456
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. 354 roberto@ausone:Build/php-4.3.2> ldd /opt/php4/bin/php libsablot.so.0 => /usr/local/lib/libsablot.so.0 libstdc++.so.5 => ...
1
8559
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the column below. The viewer can select states from the drop down lists above the other two columns as well. If the viewer selects only one, only one...
4
18241
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the user comes back to a page where he had a submitted POST data the browser keeps telling that the data has expired and asks if repost. How to avoid...
1
6799
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url http://www.mis.gla.ac.uk/biquery/training/ but each of the courses held have maximum of 8 people that could be
2
31371
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value to :parameter I dont like the idea of making the SQL statement on the fly without binding parameters as I dont want a highly polluted SQL cache.
3
23553
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the results of the picture half the size. The PHP I have installed support 1.62 or higher. And all I would like to do is take and image and make it fit a...
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.