471,321 Members | 1,627 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,321 software developers and data experts.

Multiple Controls

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.


Jul 21 '05 #1
0 916

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Gaetan | last post: by
3 posts views Thread by Shikari Shambu | last post: by
3 posts views Thread by Nathan Sokalski | last post: by
11 posts views Thread by Ranginald | last post: by
3 posts views Thread by =?Utf-8?B?a3dvbmd0aw==?= | last post: by
reply views Thread by rosydwin | last post: by

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.