473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Help... access tabpage controls

Shinobi
i have a tabcotrol(dotnetmagic) in c#.net and i am trying to create a tabpage containing a

richtextbox which is created at runtime.

richtextbox rch=new richtextbox();
Crownwood.Magic.Controls.TabPage tb1 = new Crownwood.Magic.Controls.TabPage("Document1", rch);

but i can't access the richtextbox control property like

rch.load();
rch.rtf etc...

can i set the properties of dynamically created controls in other events.?

Help me...
Nov 17 '08 #1
2 2279
nukefusion
221 Expert 100+
From the small code sample you provided it looks like you are declaring the RichTextBox within the constructor or another method. This means that the RichTextBox is privately scoped to that constructor or method. Even though the control is then added to the TabPages controls collection, you won't be able to access it's properties or methods outside of the constructor or method within which it was created, as in this sample:

Expand|Select|Wrap|Line Numbers
  1.         /// <summary>
  2.         /// Creates an instance of my form
  3.         /// </summary>
  4.         private myForm()
  5.         {
  6.             RichTextBox rch = new RichTextBox();    // Variable is privately scoped
  7.             Crownwood.Magic.Controls.TabPage tb1 = new Crownwood.Magic.Controls.TabPage("Document1", rch);
  8.         }
  9.  
  10.         /// <summary>
  11.         /// Does some stuff
  12.         /// </summary>
  13.         private void myMethod()
  14.         {
  15.             rch.Text = "Hello";     // <-- Won't compile. Can't see RichTextBox rch as it's declared within constructor.
  16.         }
To fix it, move the declaration of the RichTextBox control outside of the constructor and give it the approriate scope, depending on where you want to reference it from. If you only want to reference it from the code of the hosting Form class then private will do.

Expand|Select|Wrap|Line Numbers
  1.         private RichTextBox rch; // Declare textbox
  2.  
  3.         /// <summary>
  4.         /// Creates an instance of my form
  5.         /// </summary>
  6.         private myForm()
  7.         {
  8.             rch = new RichTextBox();   
  9.             Crownwood.Magic.Controls.TabPage tb1 = new Crownwood.Magic.Controls.TabPage("Document1", rch);
  10.         }
  11.  
  12.         /// <summary>
  13.         /// Does some stuff
  14.         /// </summary>
  15.         private void myMethod()
  16.         {
  17.             rch.Text = "Hello";     // <-- Compiles OK. 
  18.         }
Nov 17 '08 #2
Thank you.
I understand my mistake.
Nov 18 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Anita C | last post by:
Hi, How do I associate or map a specific column in a datatable to a particular element present in an xml document - to read into a datatable as well as write from the datatable to the xml element?...
2
by: JG | last post by:
Hi, I have a windows form with a TabControl on it. It has 3 tabpages on it. I have also coded a button that is supposed to 'add' a new tabpage. The code in that clicked event looks like this:...
3
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...
5
by: meh | last post by:
New to C#... I have a tab page with a handful of controls on it (label, combobox, etc.). Is it possible to "boilerplate a tabPage with the controls "like a MDI childForm" so that adding a new...
5
by: slylos | last post by:
I have an app written in C# (obviously). Here is my dilemma: The form loads, instantiates a bunch of worker threads that execute one at a time. When one finishes, it starts the next one in...
7
by: Richard | last post by:
I have a form with seven tapages. These span only one record with a large number of fields (textboxes). On Tabpage1 I display a number of read-only text boxes. This displays information about...
2
by: Hexman | last post by:
Off on another journey through vb.net. What I want to do now is have a tab-control with 1 to 8 tab-pages for categories. I've read where there is not a hide method so I guess I'll have to...
0
by: Marc Solé | last post by:
Hi to everybody, I would like o clone a tabPage into the same tabControl with all the controls of the first tabPage. I have tried doing like this, but that way doesn't clone the controls. That...
32
by: =?Utf-8?B?U2l2?= | last post by:
I have a form that I programmatically generate some check boxes and labels on. Later on when I want to draw the form with different data I want to clear the previously created items and then put...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.