I am making a custom Listbox (for the compact framework).
I have made an event (OnDrawItem). I would like to know how to get my custom event to show up in the event list in the properties window in Visual Studio.
I am using C# and Visual Studio 2008.
Here is an example of my class with the event:
class OwnerDrawnListBox<T> : System.Windows.Forms.Control
{
// Other List Box things
public DrawItemEventHandler DrawItemEventHandler { get; set; }
public OwnerDrawnListBox()
{
// ListBox init stuff
}
// Other ListBox Stuff
}
The code in your example does not create an event, you’ve created a property. You need to use the
eventkeyword:If it doesn’t show up in the properties grid straight away, you might need to rebuild your project. Also, you might want to consider renaming your event to so that it doesn’t have the same name as the delegate name (remove the “EventHandler” bit or call it something like “ItemDrawn”).