i have datagridview , want copy exact row gets selected user same position (above). have right inserts line above current line selected not copying values. i'm using basic grid, no dataset or datatables. heres code.
if dgvpcprevmonth.selectedrows.count > 0 dgvpcprevmonth.rows.insert(dgvpcprevmonth.currentcell.rowindex, dgvpcprevmonth.selectedrows(0).clone) else messagebox.show("select row before copy") end if
the clone method clones row, not data in it. you'll have loop through columns , add values after inserting it
public function clonewithvalues(byval row datagridviewrow) _ datagridviewrow clonewithvalues = ctype(row.clone(), datagridviewrow) index int32 = 0 row.cells.count - 1 clonewithvalues.cells(index).value = row.cells(index).value next end function the code taken directly msdn link provided below
Comments
Post a Comment