Windows Develop Bookmark and Share   
 index > Windows Forms General > Handling Events from listBox
 

Handling Events from listBox

How to write Event which keeps checking weather listBox1 is empty or not, and if it finds it empty disables the button1, but when something is added to the list it enables the buton1 automatically.

Thanks!
Antuntun  Monday, September 24, 2007 9:29 AM

I suggest creating your own control inheritedfrom ListBox. Create listBox1 from your class instead of the original ListBox. Inside your class, provide methods for adding and removing elements. These functions would fire as appropriatean event defined in your class to signal wheter the list has changed from empty to non-empty or viceversa. You can then connect your client code to that event to enable/disable the button1.

Alberto Poblacion  Monday, September 24, 2007 10:07 AM

I suggest creating your own control inheritedfrom ListBox. Create listBox1 from your class instead of the original ListBox. Inside your class, provide methods for adding and removing elements. These functions would fire as appropriatean event defined in your class to signal wheter the list has changed from empty to non-empty or viceversa. You can then connect your client code to that event to enable/disable the button1.

Alberto Poblacion  Monday, September 24, 2007 10:07 AM

You can use google to search for other answers

Custom Search

More Threads

• Environment.Exit(code) doesn't exit with that code
• showing blank instead of value in datagrid
• ODBC administrator
• ActiveX control crashing app when hitting 'x", but not "stop" in debugger. Started in VS2005
• Using Propertygrid Collection Editor for editing Hashtables
• Mouse Wheeling
• Extract selected content from a web browser control?
• Discovery and modification thru scripting
• OnPaint of NumericUpDown Control
• Triggering UserControl events from a subcontrol