winforms - Current selected value in DataGridView using C# -
i'm trying current selected value datagridview
messagebox.show(""+datagridview1.selectedcells.tostring()+"")
but never shows selected value.
it shows
system.windows.forms.datagridviewselectedcellcollection
you should way
messagebox.show(datagrdiview1.selectedcells[0].value.tostring());
try access value or text of single cell, , not entire collection
you can iterate through entire selectedcells
collection
string text; foreach (datagridviewcell cell in datagridview1.selectedcells) { //messagebox.show(cell.value.tostring()); text +=cell.value.tostring(); } messagebox.show(text);
Comments
Post a Comment