Newbie Q: Window Form Modifications during run-time: C#

D

Defender

Hi All,

This is my first post.

I have written a Windows Form Program (lets call it WFPA) that pops up
another windows form and threads it off (lets call this second form
WFPB). Within WFPB I have a group box. This GroupBox contains several
CheckBoxes. Everything works great.

Now, during run-time, I want to on the fly change the number of
CheckBoxes in WFPB. The instructions to change the number of
CheckBoxes comes from my calling program WFPA.

When I do this I get the following error:
"Controls created on one thread cannot be parented to a control on a
different thread."

It appears that I can only set the number of CheckBoxes in WFPB during
the initial instantiation.

My QUESTION:
How can I allow the WFPA program to update WFPB without causing the
program to invoke an exception?

Regards
Darryl Pike
 
N

Nicholas Paldino [.NET/C# MVP]

Darryl,

What do you mean by "thread" the second form off? You should be showing
it in the main UI thread.

Hope this helps.
 
D

Defender

Yes, I think that is what I am doing...
Sorry for the confusion.. I have not threaded it off...
I am new to C# and the Windows Form enviroment..

Any other suggestions
D
 
D

Defender

The second time around I use this bit of code..

this.gpbx_DataStream = new System.Windows.Forms.GroupBox();
this.gpbx_DataStream.SuspendLayout();
this.SuspendLayout();

// Alter Group Box Container...

this.gpbx_DataStream.ResumeLayout();
this.ResumeLayout();
this.gpbx_DataStream.Location = new System.Drawing.Point(chkbx_DS_X,
chkbx_DS_Y);


But is does not like it.. and throws an exception
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top