hi,
I have managed to draw buttons for each item in a listbox, by overriding the OnDrawItem event. My plan is to create a button object that will replace the drawn button for the item the mouse is hovering over. I will also need to have a button click event. Now this is where I need guidance.
Anyone have any ideas on how I should approach this
Thanks in advance,
quincy

Buttons for each item in a listbox?
RameshKandukuri
Hi quincy,
I am just including a simple code snippet. You can tweak this according to your requirements.
When you want to create the button programmatically write the following:
Button b1 = new Button();
b1.Text= "test";
b1.Click +=new EventHandler(b1_Click);
this.Controls.Add (b1);
Later in another part of the code add the following method:
private void b1_Click(object sender, EventArgs e)
{
//action to be taken on the click of the newly created button
..
}
You can replace Click with any other event that you wish to raise.
Hope that helps,
Regards,
Mamta
Charles Levy
Thanks for your reply Mamta,
What I managed to do was similar to you suggestion.
I have a class that inherits Listbox class which has a Button variable that I use to display when tracking the MouseMove event. In the MouseMove event I get the rectangle region of the highlighted item and set the location of the button to appear on the same position as the highlighted item.
So each time a mouse hovers over an item a button will also appear on the far right of that item.