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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how to set GridControl column header

Thread ID:





88374 Jul 21,2009 03:59 AM UTC Jan 11,2016 02:00 PM UTC WinForms 3
Tags: GridControl
Stephen Hui
Asked On July 21, 2009 03:59 AM UTC


I am using the sample code from "DropdownGrid_2008" to play around and trying to add headers to the drop down grid.

this is the code snippet:

this.GridB.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Office2007Blue;
this.GridB.Properties.BackgroundColor = System.Drawing.Color.FromArgb(((System.Byte)(227)), ((System.Byte)(239)), ((System.Byte)(255)));
this.GridB.Properties.GridLineColor = System.Drawing.Color.FromArgb(((System.Byte)(208)), ((System.Byte)(215)), ((System.Byte)(229)));
this.GridB.DefaultGridBorderStyle = GridBorderStyle.Solid;
this.GridB.ForeColor = System.Drawing.Color.MidnightBlue;
this.GridB.Font = new System.Drawing.Font("Verdana", 8.5F);
string[] header = new string[6];
header[0] = "Stephen";
header[1] = "Kenneth";
header[2] = "Nancy";
header[3] = "Ivy";
header[4] = "Clara";
header[5] = "Paddy";
this.GridB.Model.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, 6), header);

I thought it is pretty simple but this does not work. Can you tell me what's wrong?


Lingaraj S [Syncfusion]
Replied On July 21, 2009 09:44 AM UTC

Hi Stephen,

Thank you for your interest in Syncfusion product.

The PopulateHeader method used to populate the Header depends upon the DataSource.

Refer the example code below:

// BindingListDatsource
IList list = new List();
for (int i = 1; i <=100; i++)
list.Add(new Foo("Syncfusion","Syncfusion"));
foos = new BindingList(list);
GridB.RowCount = foos.Count;
GridB.ColCount = 2;
GridB.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, 2), foos);
GridB.PopulateValues(GridRangeInfo.Cells(1, 1, gridControl1.RowCount, gridControl1.ColCount), foos);

// DataTable DataSource
DataTable dt = GetTable();
GridB.RowCount = dt.Rows.Count;
GridB.ColCount = dt.Columns.Count+1;
GridB.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, dt.Columns.Count), dt);
GridB.PopulateValues(GridRangeInfo.Cells(1, 1, gridControl1.RowCount, gridControl1.ColCount), dt);

If you want to set the HeaderText in GridControl, then please try using Text porperty in GridStyleInfo to achieve this behavior.

Refer the code below:

GridB[0,1].Text="Header1"; // Set the Header text for First header cell

Please let me know if you have any queries.

Lingaraj S.

Ildar Sadykov
Replied On January 7, 2016 11:13 PM UTC

This works only up to 10 columns. After 10 columns there are no names.
How to fix that?

Attachment: syncfusion_grid_column_name_limit_10_11067010.zip

Mahendran Annamalai [Syncfusion]
Replied On January 11, 2016 02:00 PM UTC

Hi Ildar,

Thanks for using Syncfusion products.

We were not able reproduce the reported issue. We have attached our simple work-around sample that working fine at our end. So, could you please revert back the attached sample to reproduce the issue or else provide the steps to reproduce this issue? That would help us to find the solution. Refer to the sample from the below location.

Sample:   GridControl_Demo

Please refer the Kb link below.


Please let us know if have any concern about this.

Mahendran A.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon