Click here to Skip to main content
15,895,011 members
Home / Discussions / C#
   

C#

 
QuestionSelected TreeView Item Pin
Alan Martinis25-Nov-06 9:24
Alan Martinis25-Nov-06 9:24 
AnswerRe: Selected TreeView Item Pin
Rob Graham25-Nov-06 10:47
Rob Graham25-Nov-06 10:47 
AnswerRe: Selected TreeView Item Pin
beatles169225-Nov-06 22:53
beatles169225-Nov-06 22:53 
QuestionSelected TreeView Item [modified] Pin
Alan Martinis25-Nov-06 9:22
Alan Martinis25-Nov-06 9:22 
AnswerRe: Selected TreeView Item Pin
Bassam Saoud25-Nov-06 22:12
Bassam Saoud25-Nov-06 22:12 
GeneralRe: Selected TreeView Item Pin
Alan Martinis26-Nov-06 12:48
Alan Martinis26-Nov-06 12:48 
GeneralRe: Selected TreeView Item Pin
Scott Dorman27-Nov-06 4:51
professionalScott Dorman27-Nov-06 4:51 
AnswerRe: Selected TreeView Item Pin
darkelv26-Nov-06 15:57
darkelv26-Nov-06 15:57 
You can use Panel, Form, Custom Controls as container for "the right side".

If you can categorize the items on the tree view, you shouldn't have to have 1 panel/form/customcontrol for each treeview node.

There is a .Tag property where you can assign an object to. You can set this property to the object that is tied to the treenode.

I am using Form as a container as an exmaple here. Let's say there are 5 categories of stuff (Class1-Class5)you want to display. when you generate the treeview's node, assign the object to the node:

TreeNode treeSalesOrder = new TreeNode("Class1 Object");
treeSalesOrder.Tag = class1_from_somewhere;

etc etc

So now you have a treeview with node that has tag tied to various objects.

Have 5 forms that display these 5 classes (DisplayClass1-DisplayClass5)

On the AfterSelect event

private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
if (e.Node.Tag != null)
{
SetDisplayPanel(e.Node.Tag);
}
else
{
SetDisplayPanel(null);
}
}

private void SetDisplayPanel(object obj)
{
this.panelDisplayOnRightSide.Controls.Clear();
if (obj != null)
{
Form form = null;
if (obj is Class1)
{
form = new DisplayClass1((Class1)obj);
}
else if (obj is Class2)
{
form = new DisplayClass2((Class2)obj);
}
else if (obj is Class3)
{
form = new DisplayClass3((Class3)obj);
}
else if (obj is Class4)
{
form = new DisplayClass4((Class4)obj);
}
else if (obj is Class5)
{
form = new DisplayClass5((Class5)obj);
}
else
{
return;
}

form.ControlBox = false;
form.FormBorderStyle = FormBorderStyle.None;
form.Dock = DockStyle.Fill;
form.MaximizeBox = false;
form.MinimizeBox = false;
form.TopLevel = false;
//form.Object = obj;
panelDisplayOnRightSide.Controls.Add(form);
form.Show();
form.BringToFront();
}
}

Now I only ripped this code from a prototype program. You can add functions that reuse the 5 forms instead of new a new form every time.
QuestionAdding new items to TreeView Pin
Mark F.25-Nov-06 8:53
Mark F.25-Nov-06 8:53 
AnswerRe: Adding new items to TreeView Pin
Not Active25-Nov-06 10:28
mentorNot Active25-Nov-06 10:28 
GeneralRe: Adding new items to TreeView Pin
Mark F.25-Nov-06 11:22
Mark F.25-Nov-06 11:22 
GeneralRe: Adding new items to TreeView Pin
Not Active25-Nov-06 14:11
mentorNot Active25-Nov-06 14:11 
QuestioncrystalReport Pin
aPerfectCircle25-Nov-06 8:18
aPerfectCircle25-Nov-06 8:18 
Questionbubble and quick method Pin
sapnju_fejinja25-Nov-06 7:33
sapnju_fejinja25-Nov-06 7:33 
QuestionRe: bubble and quick method Pin
CPallini25-Nov-06 8:50
mveCPallini25-Nov-06 8:50 
AnswerRe: bubble and quick method Pin
sapnju_fejinja25-Nov-06 9:47
sapnju_fejinja25-Nov-06 9:47 
GeneralRe: bubble and quick method Pin
Rob Graham25-Nov-06 10:38
Rob Graham25-Nov-06 10:38 
GeneralRe: bubble and quick method Pin
Paul Conrad25-Nov-06 11:28
professionalPaul Conrad25-Nov-06 11:28 
GeneralRe: bubble and quick method Pin
CPallini25-Nov-06 10:41
mveCPallini25-Nov-06 10:41 
QuestionPoint Of Sale Project Pin
Waskira25-Nov-06 7:06
Waskira25-Nov-06 7:06 
QuestionOut-of-memory Exception Pin
yonidebest25-Nov-06 5:57
yonidebest25-Nov-06 5:57 
AnswerRe: Out-of-memory Exception Pin
S. Senthil Kumar25-Nov-06 6:32
S. Senthil Kumar25-Nov-06 6:32 
QuestionRe: Out-of-memory Exception Pin
yonidebest25-Nov-06 9:07
yonidebest25-Nov-06 9:07 
AnswerRe: Out-of-memory Exception Pin
Argus225-Nov-06 12:52
Argus225-Nov-06 12:52 
GeneralRe: Out-of-memory Exception Pin
yonidebest26-Nov-06 10:43
yonidebest26-Nov-06 10:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.