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. Image for the cookie policy date
close icon

PopulateHeaders

I tried to use the Method PopulateHeaders, but all that is shown is the word "Value" at position 0. Does this Method only work for ColumnHeaders or also for RowHeaders? How does it work? Thanks for help in Advance! Barbara

14 Replies

AD Administrator Syncfusion Team February 7, 2003 08:54 AM UTC

This method will not work with the GridDataBoundGrid, but should work with a GridControl. For a GridDataBoundGrid, you set the header text with the GridBouondColumn.HeaderText property. So, if you have explicitly added GridBoundColumsn to your grid, you woul duse code such as: this.gridDataBoundGrid.GridBoundColumns[col].HeaderText = "MyHeader"; if you have not explicitly added columns, you can use this.gridDataBoundGrid.Binder.InternalColumns[col].HeaderText = "MyHeader"; If you are trying the PopulatHeaders with a gridcontrol, can you post some more information about the datasource and the code you are using?


BA Barbara Arz February 10, 2003 05:40 AM UTC

I am using the gridControl. This is the code I wrote: string[] _header = new string [] {"Heat","Status","Cast"}; grid.PopulateHeaders(GridRangeInfo.Cells(0,0,1,3),_header); Whats wrong? Barbara


AD Administrator Syncfusion Team February 10, 2003 10:18 AM UTC

Try grid.PopulateHeaders(GridRangeInfo.Cells(0,1,0,3),_header);


BA Barbara Arz February 10, 2003 11:56 AM UTC

no,no! I am sorry, but this neither works! I am helpless! Barbara


AD Administrator Syncfusion Team February 10, 2003 06:56 PM UTC

Barbara, the PopulateValues method only works for column headers, not row headers. What you can do instead is simply set the cell value for the row header Example: myGrid[rowIndex, 0].Text = "Row Header Text" myGrid[rowIndex+1, 0].Text = "Row Header Text2" etc. Stefan


BA Barbara Arz February 11, 2003 05:50 AM UTC

Yes, but how does ist work. Can you write 2 lines of code, which are working correct and is using the function PopulateHeader? For what is the GridRangeInfo parameter needed in this function? Barbara


AD Administrator Syncfusion Team February 11, 2003 03:37 PM UTC

The intention is that if you have for example a DataTable you can call PopulateValues to populate the values of the table into a certain range of cells within the grid. The PopulateHeaders method can then be used to populate the field names into a range of cells above as headers. So the range info specifies where the fieldnames of the datasource should be copied to. Attached find a sample project. Instead of a custom collection you could also use a DataTable as datasource. Stefan


PA pal March 7, 2003 07:19 AM UTC

This does not work for me. I cannot set the text for the row headers. I mean, it does not error, just does not do anything. > Example: > > myGrid[rowIndex, 0].Text = "Row Header Text" > myGrid[rowIndex+1, 0].Text = "Row Header Text2" > etc. > > Stefan


AD Administrator Syncfusion Team March 7, 2003 07:35 AM UTC

That code should work for a GridControl, but will not work for a GridDataBoundGrid. If something is not in your DataSource, you cannot use an indexer to get/set it in a GridDataBoundGrid. And RowHeaders are normally not in a DataSource. To set row headers in a GridDataboundGrid, you can handle the PrepareViewStyleInfo event, and when e.ColIndex = 0, set e.Style.Text to the header you want to see for the row specified in e.RowIndex.


PA pal March 7, 2003 08:26 AM UTC

Yes, it is a databound grid. You should emphasize these type of info in your doc. But it still does noy works: private void dg_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e) { if (e.ColIndex == 0) e.Style.Text = "Test"; } It works for the first row, which is the column header and irrelevant, but does not work for other rowheaders. Pal


AD Administrator Syncfusion Team March 7, 2003 12:17 PM UTC

Oops. The GridDataBoundGrid uses a special row header cell to display the record position icon in the header cell. This particular celltype ignores any text that is set in the style. So, to see your header text, you would also have to change the celltype as well. Try this code.
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
	if(e.ColIndex == 0 && e.RowIndex > 0)
	{
		e.Style.CellType = "Header";
		e.Style.Text = string.Format("row{0}", e.RowIndex);
	}
}


PA pal March 7, 2003 01:13 PM UTC

Thanks, it works finally. Actually I tried this , but on the form onload, which was quite useless... I tried this after realising that changing the celltype in the designer does not actually changes the rowheader celltype... While we are here, how I can extract the display info of a cell which has griddropdownlist type, because cellvalue and text gives back the underlying valuemember value, not the text which is displayed on the screen?


AD Administrator Syncfusion Team March 7, 2003 01:46 PM UTC

Try the GridStyleInfo.FormattedText property.


PK Pal Koncsik March 8, 2003 09:22 PM UTC

Thanks, this is what I call customer support. This beats hands down Infragistic and other grid products I had been trying recently.

Loader.
Live Chat Icon For mobile
Up arrow icon