BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
I need fill a grid control from a datatable |
In order to copy the values form a data table to GridControl, PopulateValues() method can be used. Please refer the below code,
//Populating values using PopulateValues method
for (int row = 1; row <= this.gridControl1.RowCount; ++row)
{
for (int col = 1; col <= this.gridControl1.ColCount; ++col)
{
this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, this.gridControl1.RowCount, this.gridControl1.ColCount),dataTable);
}
}
Already we have provided this in our User Guide. Please refer the below link.
Note
The VirtualGrid is specifically designed to view the data which are in virtual mode (i.e. To view the data in data table, ArrayList, etc.,). Already we have provided the UG for Virtual Grid. Please make use of below link,
|
Is possible change header names and hide number of rows? |
Suggestion 1
The header text can be changed using Text property. Please refer the below code,
gridControl1[0, 1].Text = "EmployeeID";
|
Suggestion 2
The header text value can also be changed using CellValue property. Please make use of below code,
gridControl1[0, 4].CellValue = "Designation";
| |
Suggestion 3
You can also set the header text using QueryCellInfo Event. Please refer the below code,
//Event Triggering
gridControl1.QueryCellInfo += GridControl1_QueryCellInfo;
//Event Customization
private void GridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if(e.RowIndex==0)
{
if(e.ColIndex==1)
{
e.Style.CellValue = "EmployeeID";
e.Handled = true;
}
if (e.ColIndex == 2)
{
e.Style.Text = "EmployeeName";
e.Handled = true;
}
}
|