473,404 Members | 2,179 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,404 software developers and data experts.

Adding a control programmatically...

I want to create a textbox programmatically and add the SAME textbox to
to different panels. This code does not work:

Dim tb As New TextBox
tb.text = "xyz"
Panel1.Controls.Add(tb)
Panel2.Controls.Add(tb)

The textbox gets added to Panel2, but not Panel1. How can i get the
textbox to go to both panels? I can get it to work by duplicating the
code block... one code block puts the textbox in Panel1 and the other
one to Panel2. But i don't want to duplicate lots of code... i'd rather
have it in one code block.

Thanks!
John

Oct 12 '06 #1
2 1317
Why would you add the same control to both panels? Create two different
text boxes. Don't forget to assign their names (and I have found Tags useful
for dynamic controls).. and assign each to the panels.
"johnb41" <js********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
>I want to create a textbox programmatically and add the SAME textbox to
to different panels. This code does not work:

Dim tb As New TextBox
tb.text = "xyz"
Panel1.Controls.Add(tb)
Panel2.Controls.Add(tb)

The textbox gets added to Panel2, but not Panel1. How can i get the
textbox to go to both panels? I can get it to work by duplicating the
code block... one code block puts the textbox in Panel1 and the other
one to Panel2. But i don't want to duplicate lots of code... i'd rather
have it in one code block.

Thanks!
John

Oct 12 '06 #2
I really need to add the same "kind" of control to 2 different panels.
The 2 panels need an identical interface.

After reading your reply, i see the problem. 2 panels cannot have the
EXACT same control. Each control is unique to itself. So i really do
need to create separate controls and then add them to the panels.

Thanks,
John

On Oct 12, 3:28 pm, "Stacey" <Stac...@community.nospamwrote:
Why would you add the same control to both panels? Create two different
text boxes. Don't forget to assign their names (and I have found Tags useful
for dynamic controls).. and assign each to the panels."johnb41" <jsbuchm...@gmail.comwrote in messagenews:11**********************@m7g2000cwm.go oglegroups.com...
I want to create a textbox programmatically and add the SAME textbox to
to different panels. This code does not work:
Dim tb As New TextBox
tb.text = "xyz"
Panel1.Controls.Add(tb)
Panel2.Controls.Add(tb)
The textbox gets added to Panel2, but not Panel1. How can i get the
textbox to go to both panels? I can get it to work by duplicating the
code block... one code block puts the textbox in Panel1 and the other
one to Panel2. But i don't want to duplicate lots of code... i'd rather
have it in one code block.
Thanks!
John
Oct 12 '06 #3

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

Similar topics

1
by: Mike Malter | last post by:
I take it that the only way to add rows to a DataList control is through DataBind? If not, how do I manually add rows to a DataList control? I have searched everywhere and can't find an example...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
18
by: Praveen Ramesh | last post by:
Hi, Is there any way to add the @Assembly reference to the aspx files programmatically from inside a custom control (when it gets dropped on to the page from the toolbox)? I have a custom...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
2
by: Wayne Deleer | last post by:
Hi All, I'm currently working on a project, and I've come to a part where I want to add data to a GridView. BUT, I want to do it programmatically, with alot of control over everything. In my...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
4
by: alun65 | last post by:
I'm attempting to programmatically build up some HTML in the code behind. Like so: // Create Hyperlink HyperLink link = new HyperLink(); link.NavigateUrl = "nice cat"; link.Text = "Cats...
6
by: alun65 | last post by:
I'm having trouble programmatically adding a user control and then setting some of it's server controls. I add the user control to the code behind and add it to a placeholder: protected void...
5
by: Nathan Sokalski | last post by:
I have css that would normally be placed in style tags in the header of the Master page that I want to add programmatically for a specific Web Content Form (the *.aspx page). How do I do this for a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.