473,323 Members | 1,550 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,323 software developers and data experts.

Windows Forms Advice - same controls on different Tabpages

Dear Windows Form Designers

I am developing an application that uses a TabControl with several
Tabpages.

On the different Tabpages I wish to allow users to have the access to
the
same controls for instance a textbox to enter a date and time string
for search.

Firstly is there anyway to display the same textbox on four Tabpages
or do
I need to have four date and time fields? How do you keep the date
and time
textboxes the same across the four Tabpages.

Secondly if you have a combobox that a user selects an account number
from,
how can you adjust each other Tabpage so that the use does not need to
reselect
the account number if they change between Tabpages?

Thanks

David

May 11 '07 #1
7 5548
On May 11, 2:37 pm, davidpryce...@yahoo.com.au wrote:
Dear Windows Form Designers

I am developing an application that uses a TabControl with several
Tabpages.

On the different Tabpages I wish to allow users to have the access to
the
same controls for instance a textbox to enter a date and time string
for search.

Firstly is there anyway to display the same textbox on four Tabpages
or do
I need to have four date and time fields? How do you keep the date
and time
textboxes the same across the four Tabpages.

Secondly if you have a combobox that a user selects an account number
from,
how can you adjust each other Tabpage so that the use does not need to
reselect
the account number if they change between Tabpages?

Thanks

David
Dear David.
You can set the Container property of the textbox each time the tab
page selection changes like this: textBox1.Container = tabPage1;

On any container change, make sure the layout is proper for your
needs.

Can you be more specific on the second question?

Hope this helps.

Cheers,
Moty.

May 11 '07 #2
For the combobox, try making it a child of the form rather than a child of
each tab page. Position it so that it is on top of the tab pages, and of
course make sure that it is on top of the z-order. This way it will appear
to be on each tab, but there will really only be one, and you won't have
several between which to keep values synchronized.

--
Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Fish Grid .NET Light: Powerful Layouts for Small Datasets
<da***********@yahoo.com.auwrote in message
news:11**********************@u30g2000hsc.googlegr oups.com...
Dear Windows Form Designers

I am developing an application that uses a TabControl with several
Tabpages.

On the different Tabpages I wish to allow users to have the access to
the
same controls for instance a textbox to enter a date and time string
for search.

Firstly is there anyway to display the same textbox on four Tabpages
or do
I need to have four date and time fields? How do you keep the date
and time
textboxes the same across the four Tabpages.

Secondly if you have a combobox that a user selects an account number
from,
how can you adjust each other Tabpage so that the use does not need to
reselect
the account number if they change between Tabpages?

Thanks

David

May 12 '07 #3
Hi Moty,

I have tried setting the textBox1.Container = tabPage1.

However, I am getting the complie error that

textBox1.Container = tabPage1;

Property or indexer 'System.ComponentModel.Component.Container' cannot
be assigned to -- it is read only.

Am I missing something there?

Thanks

David
May 13 '07 #4
Here is the actual code I tried.

private void tabControl1_Selecting(object sender,
TabControlCancelEventArgs e)
{
TabControl senderTabControl = (TabControl)sender;
if (senderTabControl.SelectedTab == tabPage1)
{
MessageBox.Show("tabpage 1");
this.textBox1.Container = textBox1;
}
else
{
MessageBox.Show("tabpage 2");
}
}

May 13 '07 #5
On May 13, 10:35 am, davidpryce...@yahoo.com.au wrote:
Here is the actual code I tried.

private void tabControl1_Selecting(object sender,
TabControlCancelEventArgs e)
{
TabControl senderTabControl = (TabControl)sender;
if (senderTabControl.SelectedTab == tabPage1)
{
MessageBox.Show("tabpage 1");
this.textBox1.Container = textBox1;
}
else
{
MessageBox.Show("tabpage 2");
}
}
Hi David,

this code will do the work (inside the SelectedIndexChanged event of
the TabControl control):

if (sender is TabControl)
{
TabControl tc = (TabControl)sender;
tc.SelectedTab.Controls.Add(textBox1);
}

The second line of the if statment will make sure the text box is
assigned to one ControlCollection.

Quote: "A Control can only be assigned to one
Control.ControlCollection at a time. If the Control is already a child
of another control it is removed from that control before it is added
to another control."

Sorry for misleading you with the Container propety.

Have a great week,
Moty
May 13 '07 #6
Moty,

Perfect. Thanks. Exactly what I wanted.

David

May 13 '07 #7
On May 13, 11:12 am, davidpryce...@yahoo.com.au wrote:
Moty,

Perfect. Thanks. Exactly what I wanted.

David
Great! :)

May 13 '07 #8

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

Similar topics

8
by: Bf | last post by:
I was creating test projects using c# and was surprised that there seems to be only a form based windows applications available. Is it safe to assume that classic window applications that utilize a...
1
by: William Sullivan | last post by:
I've spent plenty of time building windows forms, but I'm working on a web project now. I've scanned a few ASP NET books, checked out some tutorials, but I am unable to figure out how to lay out...
6
by: | last post by:
Just a general question... When working with a form containing a treeview or similar control... if you need to show different form fields depending on what is selected in the treeview then what...
1
by: Luc | last post by:
Hi, I have a TabControl and, at runtime, I need to add some tabpages. The problem is that each tabpage is similar to the others and contains several controls. If I do...
5
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
by: Carlao | last post by:
I am using Windows Forms with vb.net. My app is a MDI and I have some child forms. My problem is when I try to use Control+Tab. If I have a TabControl control with some tabpages in the main form...
0
by: bosco | last post by:
Hey, I'm using a TabControl in my app, and at the moment I have 5 TabPages. Each tab page will have the exact same controls but will constitute an instance of a custom object I have created. ...
3
by: bsturg21 | last post by:
Hello, I have a windows form that has a series of linklabels on it, and I need to have each linklabel, when clicked, open a separate windows form that has a single paramter passed into it. The...
21
by: Dan Tallent | last post by:
In my application I have a form (Customer) that I want to be able to open multiple copies at once. Within this form I have other forms that can be opened. Example: ZipCode. When the user enters...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.