Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
GeneralRe: FileInfo.ValidateFIleName Pin
Not Active4-Feb-04 8:38
mentorNot Active4-Feb-04 8:38 
GeneralRe: FileInfo.ValidateFIleName Pin
John Kuhn4-Feb-04 8:48
John Kuhn4-Feb-04 8:48 
GeneralXML Web Services question Pin
Chen Venkataraman4-Feb-04 7:23
Chen Venkataraman4-Feb-04 7:23 
GeneralRe: XML Web Services question Pin
Andy Brummer4-Feb-04 8:56
sitebuilderAndy Brummer4-Feb-04 8:56 
GeneralRe: XML Web Services question Pin
Heath Stewart4-Feb-04 8:59
protectorHeath Stewart4-Feb-04 8:59 
GeneralRe: XML Web Services question Pin
Michael Potter4-Feb-04 9:15
Michael Potter4-Feb-04 9:15 
GeneralTab control question Pin
Shizam4-Feb-04 5:47
Shizam4-Feb-04 5:47 
GeneralRe: Tab control question Pin
Heath Stewart4-Feb-04 6:04
protectorHeath Stewart4-Feb-04 6:04 
All you need to do is associate a Type with your TreeNode and create an instance of that when needed. You could also instantiate an instance with each TreeNode, but that would make memory consumption very high (depending on how many TreeNodes you have).

For example, derive from TreeNode with your own class and add a ControlType property (or whatever you want to call it) of type Type. In the handler for the TreeView.AfterSelect method, you can do something like this:
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
  Type t = ((MyTreeNode)e.Node).ControlType;
  Control c = (Control)Activator.CreateInstance(t);
  containerControl.Controls.RemoveAt(0); // Assumes single control
  containerControl.Controls.Add(c);
}
The containerControl represents the Panel or whatever hosts the control to be created in your form on the right side. Please note that this is a very simplistic example but should give you some idea.

There's also a few articles here on CodeProject that use a similar approach for tree-driven preference dialogs/controls. For one example, see A Designable PropertyTree for VS.NET[^].

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Tab control question Pin
Shizam4-Feb-04 8:00
Shizam4-Feb-04 8:00 
GeneralRe: Tab control question Pin
Alex Korchemniy4-Feb-04 8:02
Alex Korchemniy4-Feb-04 8:02 
GeneralRe: Tab control question Pin
Heath Stewart4-Feb-04 8:44
protectorHeath Stewart4-Feb-04 8:44 
GeneralRe: CrystalReportViewer Pin
Alex Korchemniy4-Feb-04 9:53
Alex Korchemniy4-Feb-04 9:53 
GeneralVS problem Pin
Judah Gabriel Himango4-Feb-04 5:26
sponsorJudah Gabriel Himango4-Feb-04 5:26 
GeneralRe: VS problem Pin
Heath Stewart4-Feb-04 5:35
protectorHeath Stewart4-Feb-04 5:35 
GeneralRe: VS problem Pin
Judah Gabriel Himango4-Feb-04 5:48
sponsorJudah Gabriel Himango4-Feb-04 5:48 
GeneralRe: VS problem Pin
Heath Stewart4-Feb-04 5:53
protectorHeath Stewart4-Feb-04 5:53 
GeneralRe: VS problem Pin
Judah Gabriel Himango4-Feb-04 6:15
sponsorJudah Gabriel Himango4-Feb-04 6:15 
GeneralMDAC Pin
Mazdak4-Feb-04 4:42
Mazdak4-Feb-04 4:42 
GeneralRe: MDAC Pin
Heath Stewart4-Feb-04 5:33
protectorHeath Stewart4-Feb-04 5:33 
GeneralRe: MDAC Pin
Meysam Mahfouzi4-Feb-04 17:31
Meysam Mahfouzi4-Feb-04 17:31 
GeneralRe: MDAC Pin
Mazdak4-Feb-04 18:59
Mazdak4-Feb-04 18:59 
QuestionAdding Custom components to Windows ContextMenu? Pin
mdundek4-Feb-04 3:26
mdundek4-Feb-04 3:26 
AnswerRe: Adding Custom components to Windows ContextMenu? Pin
Heath Stewart4-Feb-04 4:34
protectorHeath Stewart4-Feb-04 4:34 
GeneralAmazing error from VisualStudio.NET Pin
Inam4-Feb-04 0:12
Inam4-Feb-04 0:12 
GeneralRe: Amazing error from VisualStudio.NET Pin
LongRange.Shooter5-Feb-04 2:27
LongRange.Shooter5-Feb-04 2:27 

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.