473,564 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding a control programmaticall y...

I want to create a textbox programmaticall y 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 1332
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********@gma il.comwrote in message
news:11******** **************@ m7g2000cwm.goog legroups.com...
>I want to create a textbox programmaticall y 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...@commun ity.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...@gma il.comwrote in messagenews:11* *************** ******@m7g2000c wm.googlegroups .com...
I want to create a textbox programmaticall y 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
4556
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 anywhere other than through building a DataTable, and then doing a DataBind. Thanks. Mike
3
4863
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 the best method? Do you have a sample of how to do this?
18
3763
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 control - MyControl that implements an interface in another custom assembly - InterfaceAssembly. When MyControl gets dropped on to the page and run, it...
6
11061
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 how those properties are set. I want to be able to do two other things: a) add User control instances to my page, filling in the place of...
2
6719
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 particular project I've passed a DataSet to a page via a Session object. The Session object passes without incident, and I can use the default...
2
15053
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 been able to find the cause of the problem, and will describe it here first textually and then through a code example. The purpose of what I am...
4
4091
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 Sleeping"; //Create Image Image img = new Image();
6
10100
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 Page_Load(object sender, EventArgs e) { UserControls_WebUserControl myControl = new UserControls_WebUserControl(); PlaceHolder1.Controls.Add(web);
5
3712
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 Web Content Form? I cannot use style tags in a Web Content Form, and I am having trouble figuring out how to add all the desired css properties to...
0
7665
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6255
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.