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

selecting custom controls in a panel

I have a windows form that has a panel on it. At runtime a custom
control is added multiple times to this panel. (anywhere from 1-50 of
them are added). I am trying to figure out how I can "select" just one
of these controls. I want this to lead to the ability to move the
controls up and down and insert/delete controls based on the current
control "selected"...

Any help/advise?

Thanks.

May 16 '07 #1
3 2468
the added custom controls are added to the panel Controls collection.
you can look for through the collection look for specific control type
or name

foreach(Control child in panelObj.Controls)
{

if ( child is TextBox && TextBox.Name = "X" )
..........

}

On May 16, 1:25 pm, Stephen.Schoenber...@gmail.com wrote:
I have a windows form that has a panel on it. At runtime a custom
control is added multiple times to this panel. (anywhere from 1-50 of
them are added). I am trying to figure out how I can "select" just one
of these controls. I want this to lead to the ability to move the
controls up and down and insert/delete controls based on the current
control "selected"...

Any help/advise?

Thanks.

May 16 '07 #2
Have you looked at adding a click delegate/eventhandler on control creation
so that when you select the custom control you can carry out the required
action.

"St******************@gmail.com" wrote:
I have a windows form that has a panel on it. At runtime a custom
control is added multiple times to this panel. (anywhere from 1-50 of
them are added). I am trying to figure out how I can "select" just one
of these controls. I want this to lead to the ability to move the
controls up and down and insert/delete controls based on the current
control "selected"...

Any help/advise?

Thanks.

May 16 '07 #3
Stephen,
When you dynamically create the control, bind the OnGotFocus event to a
method. When the control is selected, the control reference is sent in the
sender of the fired event. Just cast the sender object to your control type
using
obj1 x = sender as obj1; (where obj1 is the type)
and then check if x is null. If not null then the cast was successful, and
you can do work on the control.

Rick D.
Contractor

"St******************@gmail.com" wrote:
I have a windows form that has a panel on it. At runtime a custom
control is added multiple times to this panel. (anywhere from 1-50 of
them are added). I am trying to figure out how I can "select" just one
of these controls. I want this to lead to the ability to move the
controls up and down and insert/delete controls based on the current
control "selected"...

Any help/advise?

Thanks.

May 17 '07 #4

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

Similar topics

19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
2
by: Novice | last post by:
I can't seem to get my Custom WebControl to output a button whose click event is associated with a particular method. Here is the code I have right now that contains a panel and there is a...
0
by: Novice | last post by:
Hey all, I've already posted this question and two posters offered suggestions and they worked - but now I would like to know why - and if possible the answer to a second question. Here is my...
1
by: Novice | last post by:
Hey all, I have finally managed to create a Custom WebControl and am using a technique from another programmer to maintain state between pages - I would just like to validate this idea. ...
3
by: Charles Zhang | last post by:
I want to create a simple server control that does thing like: <Mc:CollapsibleControl TitlePanelID="panel1" BodyPanelID="Panel2"> <asp:Panel ID="panel1"> ... </asp:Panel> <asp:Panel...
0
by: Walter | last post by:
Hi, can someone please help me with my custom control viewstate problem....I haven't slept for hours trying to get this fixed. I am making two custom controls which will be included on a single...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
0
by: Stephen.Schoenberger | last post by:
I have a windows form that has a panel on it. At runtime a custom control is added multiple times to this panel. (anywhere from 1-50 of them are added). I am trying to figure out how I can "select"...
2
by: Olorin | last post by:
I'm encountering some weird behavior with the ClientID property. Let's see if I can give you enough info and if anyone has ideas/suggestions. I'm working in ASP.NET 2.0. I have a Web Project with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.