If i have a ultrawingrid with derived columns 9columns calculated from other columns), how do i get all the rows (with header row) in a datatable? Thanks
Hi Sandeep,
There's no built-in way to convert the grid's data into a DataTable. You would have to loop through the grid columns and build your DataTable, then loop through the rows and populate your DataTable rows.
Thanks. Can you give sample code for that?
Here's a very simple-case code example I created:
UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[0]; DataTable dt = new DataTable(); foreach (UltraGridColumn gridColumn in band.Columns) { dt.Columns.Add(gridColumn.Key, gridColumn.DataType); } foreach (UltraGridRow row in this.ultraGrid1.Rows) { List<object> cellValues = new List<object>(row.Cells.Count); foreach (UltraGridCell cell in row.Cells) { cellValues.Add(cell.Value); } dt.Rows.Add(cellValues.ToArray()); }