Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 4th, 2008, 10:52 AM
Friend of Wrox
 
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default TabControls dont want my buttons

this is my code inserted in the tvMSNContacts_OnDoubleClick() Method. tv is treeview.
            // This is the page that has the textbox with the IM's
            // conversation, the send button, and the close button.
            // Its part of my instant messenger.
            TabPage tpContact = new TabPage((string)Email);
            // I want to make the tpContact's name based on the
            // Buddies email

            // Make a textbox in the tab to hold incomming and
            // outgoing messages.
            TextBox tbConversation = new TextBox();
            tbConversation.Multiline = true;
            tbConversation.Dock = DockStyle.Top;
            tbConversation.Height += 200;
            tpContact.Controls.Add(tbConversation);

            // Make a button to send the data to your buddy
            Button btnSendData = new Button();
            btnSendData.Text = "Send";
            btnSendData.Location = new Point(263, 329);
            btnSendData.Click +=new EventHandler(btnSendData_Click);
            btnSendData.Show();

            // Make a button to close this tab.
            Button btnCloseTab = new Button();
            btnCloseTab.Text = "Send";
            btnCloseTab.Location = new Point(6, 329);
            btnCloseTab.Click += new EventHandler(btnCloseTab_Click);
            btnCloseTab.Show();

            // This is where i get the problem. The debugger
            // highlights "tcMSNConversation.Controls.Add
            // (btnSendData);"
            // Once this is fixed i would imaging the 3rd line gets
            // highlighted as well.
            tcMSNConversations.Controls.Add(tpContact);
            tcMSNConversations.Controls.Add(btnSendData);
            tcMSNConversations.Controls.Add(btnCloseTab);

So how do i get the tab to show up with my contacts email as its text and how does the tab control get buttons on it? i did it in the designer but i need it done programatically because these tabs are going to show up whenever i get an incomming message or i double click a contacts name.

 
Old April 4th, 2008, 11:55 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

hi iceman,

Whats the error it gives you when the exception is thrown?

Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://www.robzyc.spaces.live.com
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>
 
Old April 4th, 2008, 06:34 PM
Friend of Wrox
 
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll

Additional information: Cannot add 'Button' to TabControl. Only TabPages can be directly added to TabControls.

thats what it says on the little window that pops up, it gives me the option to break or continue.

Additional information: Cannot add 'Button' to TabControl. Only TabPages can be directly added to TabControls.

maybe i am adding to the tab and not the tab page? Im gona experiment with that idea

 
Old April 4th, 2008, 06:39 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

The error explains the problem.

TabPages are what you need to add to your TabControl, not buttons. The TabPage will give you all of the functionality needed to flip back and forth between your various IMs.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old April 5th, 2008, 05:48 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

And the Exception Details shall set you freeeee! :)

Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://www.robzyc.spaces.live.com
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>





Similar Threads
Thread Thread Starter Forum Replies Last Post
I dont know what the topic is?! Apocolypse2005 Beginning VB 6 3 August 20th, 2007 12:44 PM
database dont exist zachatcoza All Other Wrox Books 2 July 31st, 2007 02:44 PM
Samples dont work Jags .NET Framework 2.0 1 April 22nd, 2005 09:39 AM
I dont understand what this program does? kyootepuffy Classic ASP Databases 2 September 9th, 2003 01:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.