Tabs In C#

  • Thread starter Thread starter Jeff Williams
  • Start date Start date
J

Jeff Williams

I want to use tabs on a form and well as some data fields.

What I want to do is each tab is additional data which needs to be saved
when the Ok button is pressed on the form.

How from the main form OK method can I access the individual data fields
on each tab so that I can use a single SQL statement to update my data.

Thanks in advance
Jeff
 
You can try making the fields public (or internal). This should allow
you to access them wherever you know a reference to the parent
TabPage. (You also may need to declare the TabControl public or
internal as well depending on whether the 'main' form you mentioned
has a reference to the TabControl).

=================
Clay Burch
Syncfusion, Inc.
 
I want to use tabs on a form and well as some data fields.

What I want to do is each tab is additional data which needs to be saved
when the Ok button is pressed on the form.

How from the main form OK method can I access the individual data fields
on each tab so that I can use a single SQL statement to update my data.

Thanks in advance
Jeff

The TabControl contains a property named, TabPages, a collection of
TabPage objects. On the other hand, each TabPage has got a Tag
property that gets or sets the object that contains data about the
control. You may use the Tag property to associated whatever data you
need with a given tab.

Hope this helps,
 
I would keep a reference as a private variable to whatever tab is
selected. Then add a function to return the selected tabpage to the
main form so the OK method can reference the values included in that tab
page. I would also include in the tabpage.tag proerty some sort of
identifier so you know which values you are working with, which is what
mehdi mentions. This way, the form with the tabpages keeps control of
its pages, and the main form is provided access to the currently
selected page.

T
 
Jeff said:
I want to use tabs on a form and well as some data fields.

What I want to do is each tab is additional data which needs to be saved
when the Ok button is pressed on the form.

How from the main form OK method can I access the individual data fields
on each tab so that I can use a single SQL statement to update my data.

Thanks in advance
Jeff
Control's placed in tabs>tabpages are automatically visible to the
parent form.
Form
Tab
Page 1
Label1
Label2

Form can access label1 and 2 if done via the visual designer.

JB
 

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

Back
Top