473,508 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TabControl.Controls.Add System.ArgumentException

since its common knowledge that it's not possible to hide a tabcontrol
tab, i made a collection for removed pages including their
tabcontrols. removing works pretty fine, but whenever i try to add a
page (timer triggered) i get stuck:

System.ArgumentException

the message is like: controls, created for a thread cannot
superordinate controls from another thread.

*outch*

i hope i made just a small mistake - so anything usefull?

regards
rené

ps: some code:
<code>
foreach(cControlInfo myControlInfo in myContainer.removedControls)
{
if (!
myControlInfo.controlParent.Controls.Contains(myCo ntrolInfo.controlChild))
{

myControlInfo.controlParent.Controls.Add(myControl Info.controlChild);
}
}
</code>

Aug 1 '07 #1
3 1925
You cant finddle with controls from a thread that didnt create them. You
should use a System.Windows.Forms.Timer which fires on the main forms thread
or you should call Invoke on the control to set the property (only really
needed if InvokeRequired property returns true, which it will do from another
thread)

HTH
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"ohmmega" wrote:
since its common knowledge that it's not possible to hide a tabcontrol
tab, i made a collection for removed pages including their
tabcontrols. removing works pretty fine, but whenever i try to add a
page (timer triggered) i get stuck:

System.ArgumentException

the message is like: controls, created for a thread cannot
superordinate controls from another thread.

*outch*

i hope i made just a small mistake - so anything usefull?

regards
rené

ps: some code:
<code>
foreach(cControlInfo myControlInfo in myContainer.removedControls)
{
if (!
myControlInfo.controlParent.Controls.Contains(myCo ntrolInfo.controlChild))
{

myControlInfo.controlParent.Controls.Add(myControl Info.controlChild);
}
}
</code>

Aug 1 '07 #2
*ahm* - i'm using the System.Windows.Forms.Timer control, so what?
can you tell me more about invoke (maybe short snipplet)?

r.

Aug 1 '07 #3
invoke just did what i needed!

for the curious ones: i've overlooked that my timer starts an
asynchron procedure - *damn*

this works fine:
<code>
//delegate
private delegate delAdder void myAdder(Control cntAddThis);

//in asynchron callback method (mainform)
this.invoke(new delAdder(myAdder), new object[]{cntAdd});
</code>

thank you very much!

Aug 2 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4653
by: Ken Lee | last post by:
Hi all, I'm sort of very new to C# and haven't programmed in OO for a while. I'm trying to override the backgroundimage to the tabcontrol but it just doesn't seem to want to do it, can someone...
3
2248
by: cdj | last post by:
Hi all, I've got a tabControl, initially with one tabPage, along with two buttons, one to add another tabPage, and one to delete the current (selected) tabPage. On each tabPage, when it is...
2
2349
by: Patrick McGuire | last post by:
I want to place a tabControl with almost identical properties on several forms. I think the best way is to define a UserControl that inherits System.Windows.Forms.TabControl, and place all my...
9
3440
by: Michael Turner | last post by:
Hi Guys Having problem with the tab control, I need to set the background color to something different than the standard, I have found code on the web and now can redraw the tabpage buttons so...
5
3718
by: scorpion53061 | last post by:
I am trying to be able to share a groupbox and its related controls among all of my tab pages. This does not error but the controls do not appear either. Thank you for your help!! ...
0
1010
by: Juan Pedro Gonzalez | last post by:
Hi, I'm running mad with this issue, hope I can explain it correctlly. I've been developping a user control wich is very similar to the TabControl... Basically my control has two panels that...
7
1910
by: Sudhakara.T.P. | last post by:
Hi, I have an tab control in one of the forms and it has two tab strips. Now I have written an general function that accepts form name as parameter and iterates through all the controls in the...
2
3339
by: Simon Verona | last post by:
I have a few hundred forms in my application. All are based on a custom base form class. I decided that I wanted to globally change the look and feel of many of the controls in my application -...
2
2832
by: Rex the Strange | last post by:
I suspect the answer to this question is "you can't," but here goes anyway: I have a tabcontrol which contains, of course, various tabpages (added programmatically at runtime, but this is...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7124
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7385
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1558
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.