Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
I have made a custom property for my usercontrol which accepts an array of buttons.

Now when I click on that property of usercontrol in properties window, it shows a dialog box called as "Button Collection Editor" in which I can add or remove new instances of buttons.

But I want to have the list of buttons which are already existing on the form in this editor.

How can I do this ?

Thanks & regards

Siddharth
Posted
Comments
Ziee-M 22-May-14 7:51am    
Hi, upvoted the question since its really intressting / original.
I am pretty sure its possible since the Property window of visual studio lists all the control present in the current form.
if you can manage to get all the control, then check the type of each one of them, then you will reach your goal.

1 solution

Hi again,

the solution was pretty easy,

check thislink to get all the form control and select specific type of your list

http://stackoverflow.com/questions/3419159/how-to-get-all-child-controls-of-a-windows-forms-form-of-a-specific-type-button[^]

Hope it helps
 
Share this answer
 
Comments
Sid_ScienceKid 23-May-14 4:16am    
Thanks for the idea Ziee, But the problem is that I want to use this method in the UITypeEditor class.
And it doesn't identify the current form or container.

Basically I have made a custom property for my usercontrol for which I want to have a checklistbox in its property window to select values for it.

So I am using UITypeEditor class to add the checklistbox to the property.

Simultaneously I want to populate this checklistbox with the number of same "usercontrol" available on the form.

in short I want to have link between usercontrols i.e in the property of usercontrol1, it should show instances of other usercontrols present on the form.

Its really challenging for me atleast. Please help If you have some idea to solve this.
Ziee-M 23-May-14 4:42am    
Its not challenging only for you, its really challenging, i will do some more resarch.
Are you able to select a list of all the userControll but can't identify those who are exactly your target? this information may help
Sid_ScienceKid 23-May-14 5:47am    
Hi Ziee, I have updated the solution again. If you can make a usercontrol with 1 Listbox and 1 Label and copy this code behind, you will get some better idea.

Then just build the solution and add this user control on the form of some new project and checkout the property "NoOfUserListOnForm" under Misc Category.

I have managed to achieve 70% of the solution i guess. But still it needs some improvements. I hope you can help me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900