473,511 Members | 16,983 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 1867
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..jwaonline..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussions.microsoft.com> wrote in message news:A2**********************************@microsof t.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..jwaonline..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussions.microsoft.com> wrote in message news:A2**********************************@microsof t.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.AfterSelect+= new TreeViewEventHandler ( TreeNodeSelected );

Controls.Add(tree);

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

private string currentViewType = null;

private void TreeNodeSelected(object sender, TreeViewEventArgs 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, "currentViewType" 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.Clear();

switch (currentViewType)
{
case "Type1":
view.Controls.Add(viewType1);
break;
case "Type2":
view.Controls.Add(viewType2);
break;
}
}

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussions.microsoft.com> wrote in message news:9E**********************************@microsof t.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..jwaonline..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussions.microsoft.com> wrote in message news:A2**********************************@microsof t.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.AfterSelect+= new TreeViewEventHandler ( TreeNodeSelected );

Controls.Add(tree);

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

private string currentViewType = null;

private void TreeNodeSelected(object sender, TreeViewEventArgs 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, "currentViewType" 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.Clear();

switch (currentViewType)
{
case "Type1":
view.Controls.Add(viewType1);
break;
case "Type2":
view.Controls.Add(viewType2);
break;
}
}

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussions.microsoft.com> wrote in message news:9E**********************************@microsof t.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..jwaonline..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussions.microsoft.com> wrote in message news:A2**********************************@microsof t.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(view);


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 "TreeNodeSelected" 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 "TreeNodeSelected" method I gave in my original
example is a handler for your TreeView's "TreeNodeSelected" 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 "TreeNodeSelected" to associate nodes with specific text to
specific views, the modified code could be changed to look like this:

private void TreeNodeSelected(object sender, TreeViewEventArgs 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.Clear();

switch (currentViewType)
{
case "Type1":
view.Controls.Add(viewType1); // viewType1 is a referene to a UserControl instance that is one of your "Views"
break;
case "Type2":
view.Controls.Add(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..jwaonline..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussions.microsoft.com> wrote in message news:FE**********************************@microsof t.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.AfterSelect+= new TreeViewEventHandler ( TreeNodeSelected );

Controls.Add(tree);

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

private string currentViewType = null;

private void TreeNodeSelected(object sender, TreeViewEventArgs 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, "currentViewType" 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.Clear();

switch (currentViewType)
{
case "Type1":
view.Controls.Add(viewType1);
break;
case "Type2":
view.Controls.Add(viewType2);
break;
}
}

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"Macca" <Ma***@discussions.microsoft.com> wrote in message news:9E**********************************@microsof t.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..jwaonline..com
>> -----------------------------------------------------------------------
>> "Macca" <Ma***@discussions.microsoft.com> wrote in message news:A2**********************************@microsof t.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
11179
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)...
2
5774
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...
3
22957
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...
0
8434
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. ...
1
8537
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...
4
18217
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...
1
6776
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 ...
2
31344
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...
3
23531
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...
0
7144
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...
0
7427
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...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5069
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...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.