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

  • Thread starter Thread starter Defender
  • Start date Start date
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
 
Darryl,

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

Hope this helps.
 
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
 
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
 
Back
Top