473,513 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implementing a DropDownList to Select a Value of a Property of a Custom UserControl

22 New Member
Hi,
I am creating a usercontrol based on the TextBox (Visual C#). I want the control to have a property that lists names of all controls in its parent form via a dropdown list in the same way the contextmenu, datasource and imagelist properties of TextBox, DataGrid and ToolBar controls respectively behave. Since the names of the controls is unknown before hand, it is clearly not feasible to use user-defined enum. Any ideas?
Jul 13 '07 #1
5 1208
kenobewan
4,871 Recognized Expert Specialist
If I understand your question correctly, one way would be to have a control array featured in the selectedindexchanged event. HTH.
Jul 14 '07 #2
gkinu
22 New Member
Thanks a lot. May be to make myself clearer.

1. I am creating a usercontrol that inherits from a TextBox.
2. One of the new properties is called 'ControlsInForm' which is basically a list of all controls in the form, just like the ImageList property of a ComboBox.
3. When i drop this usercontrol onto a from at design time, i expect a list of the names of all controls in the form to be displayed as a list in this property from where i can select one.

I hope this is better.
Jul 16 '07 #3
kenobewan
4,871 Recognized Expert Specialist
Is this a windows form? When you say drop at design time, the user can drag this and have all the form controls listed or the form controls are already listed once the form is displayed?
Jul 16 '07 #4
gkinu
22 New Member
Yes. It is a windows form. The new usercontrol should have a property that shows a dropdown list of names of other controls in the form just like the ImageList property of a ToolBar will contain dropdownlist of all ImageList controls in the form; from which you can select one.
Aug 8 '07 #5
Floydan
24 New Member
I'm not sure if this is usefull, but you can get all the controls of a windows form by just writing (if you are in the Class inheriting from Form) this.Controls <- this will return a ControlCollection.
You should be able to retreive the form object by looking at your usercontrols owner?


Yes. It is a windows form. The new usercontrol should have a property that shows a dropdown list of names of other controls in the form just like the ImageList property of a ToolBar will contain dropdownlist of all ImageList controls in the form; from which you can select one.
Aug 8 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1892
by: adam | last post by:
i have custom user control and i'm trying to pass values to custom user control......I need help it seems to me i cannot pass the value to user control from dropdownlist. I have property in a...
2
3100
by: Benedict Teoh | last post by:
I created a dropdownlist containing day, month and year field and expose a property to assign a date. When I call from a aspx page and assign the value, the new date is not displayed until a submit...
0
2501
by: RyanG | last post by:
when the value that determines the filter is databound?? I am trying to make a DropDownList for a set of data that I use a lot throughout my project. So I extended the DropDownList to retrieve...
10
10713
by: dhnriverside | last post by:
Hi guys Still having a problem with this dropdownlist. Basically, I've got 4. The first 2 work fine, then my code crashes on the 3rd. ddlEndTimeHour.Items.FindByValue(endTime).Selected =...
5
3198
by: gane kol | last post by:
Hi I have a custom validator that validates a dropdownlist with a listitem value as "". But the clientvalidation function is never called. but if i use value = "0" and check it in javascript, it...
1
2352
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
1
2552
by: Joe | last post by:
Hello All: I have created a class (UpdatedDropDown) that inherits from DropDownList and I have included the following code in this class: Public Class UpdatedDropDown Inherits DropDownList ...
2
2267
by: Michael | last post by:
Hi again, I really hope that there is a simple solution to this one, cause I'm having simular things happening to other controls on this usercontrol. I have the following control:...
1
2019
by: DJ | last post by:
I have a DropDownList in Visual Web Developer that is databound to a SQL Database. Whenever the web page is opened the DropDownList is automatically filled with the first item in the table. My...
0
7260
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
7161
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...
1
7101
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
7525
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5686
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
4746
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...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.