473,320 Members | 1,867 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,320 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 2464
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: 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: 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...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.