We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Adding rows to datagrid

How do I add a new row to the data grid? I have also tried the code to select a row when a cell is clicked. But how do I revert it back to just selecting the cell?

1 Reply

CB Clay Burch Syncfusion Team June 1, 2002 04:26 AM

You have to add the rows to the underlying datasource. If the datagrid's datasource is a datatable, then code such as this should append rows. DataTable dt = (DataTable) this.dataGrid1.DataSource; //if table has two text columns dt.Rows.Add(new object[] {"Blah1", "Blah2"}); dt.AcceptChanges(); To selectively have single row selection, you could add a bool property to the derive datagrid, and text this property in the two mouse overrides. If this property is true, execute the code that is there now. If this property is false, just call the base class for each of the mouse overrides. This should return the functionality to the default selection behavior.

Loader.
Live Chat Icon For mobile
Up arrow icon