SSK
SSK

Reputation: 803

Adding Events to user control in Windows forms

I am using a windows form in which i have a build a usercontrol with one textbox and one CheckedList control. What i wanted to do is i want to capture the ListIndexChanged event of CheckListbox control in my form where i use this usercontrol.

Please help me how to do this

Upvotes: 1

Views: 1659

Answers (1)

Itay Karo
Itay Karo

Reputation: 18306

You can add this

public event EventHandler SelectedIndexChanged
{
    add { checkListBox.SelectedIndexChanged += value; }
    remove { checkListBox.SelectedIndexChanged -= value; }
}

to your control and subscribe to this event from the form

take a look here

Upvotes: 2

Related Questions