Dear All,
I have a TreeView, TextBox, Label, and ToolStrip control that I am
reusing again and again. There are also some interactions between the
controls that are always the same. Therefore, I did put them in a Panel
so facilitate reuse.
The "problem" is that the content of the TreeView (including the images
at the branches), the ToolStripItems for the ToolStrip, the Text for
the Label, etc is always different. First I wanted to add member
functions to configure these controls but then I figured I would just
replicate a lot of these controls' native interface. So I ended up
making the controls public.
Now I have two forms form1 and form2 in a main form. form1 contains the
panel mentioned above. form2 needs to know the text associated with the
currently selected node in form1.myPanel.treeView1. For that I have a
function GetSelectedNodeText(){return
myPanel.treeView1.SelectedNode.Text;}. The problem is that treeView1
throws the following exception: "Illegal cross-thread operation:
Control 'treeView1' accessed from a thread other then the thread it was
created on." So the questions are:
1) Why do I get the above exception?
2) What is the best way to combine controls but still give lots of
fexibility to set them up, i.e. set the text for the Label control, set
the ToolStripItems for the ToolStrip, etc, etc.
Thanks,
Rob