I learn to use ObjectListView in C# to show my MySQL data and I try to draw/put a delete button inside column so that when I click it, it will delete the row.
I know how to draw an image or a progress bar inside a column, but the problem is I don't know how to put a button inside. When I search Google, I found that someone said have to use custom renderer to draw a button, but I don't know how.
How to put button inside the column?
This answer explains how to use the CellEditStarting event to delete a row when a specific column of that row is clicked.
You only have to add a custom renderer to that solution if you want to display some kind of delete symbol.
You don't have to implement a custom renderer to display some kind of button-image for that row. You can use the ImageGetter. I improved the answer i already referenced to. It contains an example now.
Extract:
// assign an ImageList containing at least one image to SmallImageList
objectListView1.SmallImageList = imageList1;
// always display image from index 0 as default image for deleteColumn
deleteColumn.ImageGetter = delegate {
return 0;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With