We're sending query results to a grid. Different columns, with different datatypes, on each query. Is there a grid control that will

a) autopopulate the columns based on the dataset that is set to be its datasource


b) correctly render the linefeeds or carriage returns that appear in a text string?

Let's say there was an address column with this data:

123 Main St@Apt #2@New York NY 10016

where instead of @ there was actually a char(10). We would like it to render in the cell as

123 Main St
Apt #2
New York NY 10016

There's no design-time preparation in which columns are defined and editors assigned. This is all ad hoc.


1 Answer 1


Essential Grid supports auto populating data from the underlying data source and the DataSource property can be used to set the data source to the Grid.

Sample link

#region DataSource 
DataTable dataTable = new DataTable(); 
for (int i = 0; i < 10; i++) 
DataRow dataRow = dataTable.NewRow(); 
dataRow[0] = i; 
dataRow[1] = "Name" + i.ToString(); 
dataRow[2] = "Category"+i; 
dataRow[3] = "Data" + i.ToString(); 
dataRow[4] = "Decription" + i.ToString(); 
//to set the data source for the grid. 
this.gridGroupingControl1.DataSource = dataTable; 

By default, the char(10) (i.e. the new line char) is addressed as “\r\b”. In order to render the char(10) value in the GridGroupingControl, the CellValue can be modified for display using the QueryCellStyleInfo event.

#region Event
//Event triggering 
this.gridGroupingControl1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo);
//Event customization 
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) 
if (e.Style.CellValue != null) 
    string cellValue = e.Style.CellValue.ToString(); 
    if (cellValue.Contains("char(10")) 
        cellValue.Replace("char(10)", "\r\b"); 
        e.Style.CellValue = cellValue; 


Syncfusion Windows Forms Grid

The entire product is available for free with no limitations through the community license if you qualify.

Note: I work for Syncfusion

  • Thanks for the info. I will take a look. Jan 9, 2018 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.