GridListControl - Column Header Text

How to change the column header text in the GridListControl.

5 Replies

AD Administrator Syncfusion Team January 11, 2007 04:20 AM UTC

Hi Sreeni,

Currently there is no property settings that you can used to change these column headers. But you can change them using the PrepareViewStyleInfo event handler. This event is a member of the embedded GridControl that is a member of the GridListControl.



Below are some code snippets.

//hook the PrepareViewStyleInfo event

this.gridListControl1.Grid.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(PrepareViewStyleInfo);

private void PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if(e.ColIndex > 0 && e.RowIndex == 0)
{
switch (e.ColIndex)
{
case 1:
e.Style.Text = "NameCol1";
break;
case 2:
e.Style.Text = "NameCol2";
break;
case 3:
e.Style.Text = "NameCol3";
break;
default:
break;
}
}
}

Best Regards,
Haneef


TR Truong November 9, 2016 09:59 AM UTC

HOW CAN I CHANGE COLUMNS NAME WITHOUT THIS EVENT ? 

I WANT TO CHANGE COLUMNS WHEN I DEFINE GRIDLISTCONTROL

EXAMPLE HIDE A COLUMN :

gridListControl2.Grid.HideCols["ID"] = true;


PM Piruthiviraj Malaimelraj Syncfusion Team November 10, 2016 05:06 AM UTC

Hi Troung, 

Thanks for the update. 
 
By default, the GridListControl used to populate the values from the underlying data source. In GridListControl, the table styles can’t be customized based on the indices of the columns or cells directly. So customizing the header text or any styles can be achieved by only using the PrepareViewStyleInfo or QueryCellInfo events. So we request you to use those events for your requirements. Thanks for your understandings. 
 
Regards, 
Piruthiviraj 



TR Truong November 10, 2016 06:54 AM UTC

Can you show me how to use QueryCellInfo events to get a text of a textbox then set into current cell
---------------------------
gridListControl1.Grid[gridListControl1.Grid.CurrentCell.RowIndex, 2].Text = 
TongPhaChe_Label.Text ;


PM Piruthiviraj Malaimelraj Syncfusion Team November 10, 2016 08:38 AM UTC

Hi Truong, 

Thanks for the update. 

We have provided the solution to change the cell text using QueryCellInfo event in the forum #127335. Please follow-up with that forum and let us know if you have any other queries. 

Regards, 
Piruthiviraj 


Loader.
Up arrow icon