C
codewriter
This will do:
this.dataGrid1.DataSource = null;
this.dataGrid1.Refresh();
"VM" <None> wrote in message How can I reset a datagrid? In my code, on an event, I do all the databinding of the datagrid to the dataset dynamically:
... //get the Dataset
DGOrders.SetDataBinding(DSMyTrans, "ClientTrans");
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "ClientTrans";
DataColProds.HeaderText = "Desc";
DataColProds.MappingName = "description";
ts1.GridColumnStyles.Add(DataColProds);
DGOrders.TableStyles.Add(ts1);
DataColProds.Width = 140;
myDataColItemNumber.HeaderText = "Item No.";
myDataColItemNumber.MappingName = "itemid";
ts1.GridColumnStyles.Add(myDataColItemNumber);
DGOrders.TableStyles.Add(ts1);
myDataColItemNumber.Width = 70;
...
What can I do so, when I click again, it erases/deletes all columns and data and regenerates it with the above code?
Thanks,
VM
this.dataGrid1.DataSource = null;
this.dataGrid1.Refresh();
"VM" <None> wrote in message How can I reset a datagrid? In my code, on an event, I do all the databinding of the datagrid to the dataset dynamically:
... //get the Dataset
DGOrders.SetDataBinding(DSMyTrans, "ClientTrans");
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "ClientTrans";
DataColProds.HeaderText = "Desc";
DataColProds.MappingName = "description";
ts1.GridColumnStyles.Add(DataColProds);
DGOrders.TableStyles.Add(ts1);
DataColProds.Width = 140;
myDataColItemNumber.HeaderText = "Item No.";
myDataColItemNumber.MappingName = "itemid";
ts1.GridColumnStyles.Add(myDataColItemNumber);
DGOrders.TableStyles.Add(ts1);
myDataColItemNumber.Width = 70;
...
What can I do so, when I click again, it erases/deletes all columns and data and regenerates it with the above code?
Thanks,
VM