datagridview - How To Move Row In DataBound DataGrid In C# without Knowing The Object Type -
i have number of datgridgs want able reorder rows for. sortablebindinglist<> : list<> types contain different objects. tried casting datagridview's datasource sortablebindinglist<object>
.removeat()
& .insert()
cast failed. tried pass object type function using type
failed.
type objtype; ... var x = (sortablebindinglist<objtype>) datagridview.datasource;
but doesn't work either, nether 'typeof(objtype)`.
not sure how proceed.
turns out can dynamic types.
dynamic list = dgv.datasource; var item = list[rowindexfrommousedown]; list.removeat(rowindexfrommousedown); if (rowindexofitemundermousetodrop == -1) list.add(item); else list.insert(rowindexofitemundermousetodrop, item);
Comments
Post a Comment