I have a listbox inside a custom control. I use this custom control into a form. I would like to be able to get the listbox index changed event when I am working into the form. How can I do that?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This can be a disadvantage of a UserControl. You have to re-publish the events and the properties of one or more of its embedded controls. Consider the alternative: if this UserControl only contains a ListBox then you are much better off simply inheriting from ListBox instead of UserControl.
Anyhoo, you’ll need to re-fire the SelectedIndexChanged event. And surely you’ll need to be able to let the client code read the currently selected item. Thus: