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

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -