I must have done something wrong, but what?
The rest of the code is from a form class that has the custom control on it.
The messageBox never pops up indicating that the event does not work. However, it works inside the control but just not outside in another class.
What am I missing?
C#:
//This is my handler and EventArgs.
//They were declared inside the namespace block of my custom control.
public delegate void ItemSelectedEventHandler(object sender, ItemSelectedEventArgs e);
public class ItemSelectedEventArgs : EventArgs
{
public int Index=-1;
public string Item="";
public ItemSelectedEventArgs()
{
Index= FileBrowserLB.selIndex;
Item= FileBrowserLB.selFile;
}
}
//This is the event variable declared inside the controls constructor:
public event ItemSelectedEventHandler ItemSelected;
The rest of the code is from a form class that has the custom control on it.
C#:
//In the forms constructor:
this.fileBrowser.ItemSelected += new ItemSelectedEventHandler(this.ItemSel);
//The method in the form that should capture the event:
void ItemSel(object sender, ItemSelectedEventArgs e)
{
MessageBox.Show(e.Index+" "+e.Item);
}
What am I missing?