c# - DataGridView Button Click Returns Wrong Index -
simple problem. have datagridview set using datatable , add 2 columns after datatable buttons. when click button has index 6, gives me index 1 first button.
datatable cartresults = cart.runcartquery(sb.tostring()); dgcart.datasource = cartresults; // add button datagridview @ specified position datagridviewbuttoncolumn btnedit = new datagridviewbuttoncolumn(); btnedit.name = "btnedit"; btnedit.text = "edit"; btnedit.headertext = "edit quantity"; btnedit.usecolumntextforbuttonvalue = true; dgcart.columns.insert((int)buttons.edit, btnedit); datagridviewbuttoncolumn btndelete = new datagridviewbuttoncolumn(); btndelete.name = "btndelete"; btndelete.text = "delete"; btndelete.headertext = "delete"; btndelete.usecolumntextforbuttonvalue = true; //dgcart.columns.insert((int)buttons.delete, btndelete); dgcart.columns.add(btndelete);
i don't know why index being returned 1 (which edit button) , not delete button index 6. ideas?
the source of problem datagridview.datasource datatable, add 2 button columns after datasource set. though i've added buttons @ index 1 , 6, datagridview thinks @ index 0 , 1. though grid looks fine on form.
Comments
Post a Comment