Tab Pages ... yet again !!!

A

amir

Hello all,
I have a little problem.
I have created a form and on it a tabControl.
to the tab control i am adding pages dynamically with a class of my
own which is called myTabPage which contains a TabPage with my own
setups (textboxs and so on...) now i want when a tab is selected and
then a save button is pressed to retrieve the new data from the tab
so
i can save it. For some reason i dont know how to catch my tab... not
with this.
dont know how to reach the page.
i know to catch the selectedTab but it sends me a tab page which does
not contain the fields that are in my tabPage , and i need to save the
data on them them but unable.
thnx,
amir.
 
B

Bruce Wood

Hello all,
I have a little problem.
I have created a form and on it a tabControl.
to the tab control i am adding pages dynamically with a class of my
own which is called myTabPage which contains a TabPage with my own
setups (textboxs and so on...) now i want when a tab is selected and
then a save button is pressed to retrieve the new data from the tab
so
i can save it. For some reason i dont know how to catch my tab... not
with this.
dont know how to reach the page.
i know to catch the selectedTab but it sends me a tab page which does
not contain the fields that are in my tabPage , and i need to save the
data on them them but unable.

Have you tried casting the object you get back to be a myTabPage, like
this:

myTabPage tp = (myTabPage)selectedTab;

?
 
P

per9000

Hello all,
I have a little problem.
I have created a form and on it a tabControl.
to the tab control i am adding pages dynamically with a class of my
own which is called myTabPage which contains a TabPage with my own
setups (textboxs and so on...) now i want when a tab is selected and
then a save button is pressed to retrieve the new data from the tab
so
i can save it. For some reason i dont know how to catch my tab... not
with this.
dont know how to reach the page.
i know to catch the selectedTab but it sends me a tab page which does
not contain the fields that are in my tabPage , and i need to save the
data on them them but unable.
thnx,
amir.

I have a similar situation where I have a class called BlackBox (that
inherits from TextBox). I have a tabpage and when I click Save I want
to call the BlackBox's Save.

The syntax is a little compact and perhaps it does not match your
situation exactly but I hope it helps:

private void ButtonSave_Click(object sender, EventArgs e)
{
((BlackBox)this.Tabs.SelectedTab.Controls[0]).Save();
}

Note that the only control on my tabpages are instances of the
BlackBox. Perhaps you want to do something similar to this:

// untested
string SaveMe = ((TextBox)this.Tabs.SelectedTab.Controls[0]).Text;
// open save file dialogue etc...


[:)]-|--<
Per

--

Per Erik Strandberg
..NET Architect - Optimization
Tomlab Optimization Inc.
http://tomopt.com/tomnet/
 

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

Top