How do I make the header in the GridDataBoundGrid invisible?

I''m using the GDBD to show some data to the user by binding it to a dataset. I need to set one of the column header''s property to invisible. How do I do this? Could someone give me the code snippet since I''ve tried finding an attribute to do this and have been unsuccessful so far. Thanks!

9 Replies

AD Administrator Syncfusion Team August 22, 2005 02:32 PM UTC

You can set the HeaderText property on the GridBoundColumn for the column to be one space (setting it to be teh empty string will not work). //if you haven''t added GridBoundColumns this.gridDataBoundGrid1.Binder.InternalColumns["Col1"].HeaderText = " "; //or if you added GidBoundColumns... this.gridDataBoundGrid1.GridBoundColumns["Col1"].HeaderText = " ";


AP Atith Pagdi August 23, 2005 04:45 AM UTC

I tried that Clay, but it still doesn''t work. There''s no change in the header text. This would however just make the text = "", but I want the column header itself to be invisible. How can we do this? I was trying the following code... GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex]; if(style.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell) { if(style.TableCellIdentity.Column != null && style.TableCellIdentity.Column.Name == "Product") e.Inner.Cancel = true; } but wasn''t able to find a reference to the GridTableCellStyleInfo class. Which namespace do I need to include for this class? (using...) Thanks.


AD Administrator Syncfusion Team August 23, 2005 06:56 AM UTC

Hi If your intension is to make the particular column header invisible , you can try the following code in the PrepareViewStyleInfo() event. if(e.ColIndex >= 1 && e.Style.CellType == GridTableCellType.ColumnHeaderCell.ToString()) { if(this.gridDataBoundGrid1.Model.NameToColIndex("Product") == e.ColIndex) e.Style.CellType = GridTableCellType.None.ToString(); } Regards Mouli.


AP Atith Pagdi August 23, 2005 08:51 AM UTC

Hi, I tried the code suggested by you, but the column header is still visible. I''ve been trying to do this for a couple of days now. Is there any other way we can handle this? Thanks, Atith


AP Atith Pagdi August 23, 2005 09:08 AM UTC

Also, on trying this... the NameToColIndex method returns the value 28 to me when there are no more than 10 columns in the grid. I have specified the layout of the datarow in the PrepareStyleInfo handler to be a multi row record. Do you think this could have anything to do with it? Thanks, Atith


AD Administrator Syncfusion Team August 23, 2005 09:32 AM UTC

You want to drawn an empty hole where the header cell is located, correct? Here is a sample using QueryCellStyleInfo. http://www.syncfusion.com/Support/user/uploads/GGC_EmptyHeaderCell_4558bc5b.zip


AP Atith Pagdi August 23, 2005 09:44 AM UTC

Clay, That''s for the GridGroupingControl. I''m trying to achieve this with the GridDataBoundGridControl.


AD Administrator Syncfusion Team August 23, 2005 10:12 AM UTC

The reason I thought you had changed to a GroupingGridControl is above you listed code like: GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex]; You use the model.QueryCellInfo event in a GridDataBoundGrid and do the same thing. http://www.syncfusion.com/Support/user/uploads/GGC_EmptyHeaderCell_dd519d5b.zip


AP Atith Pagdi August 23, 2005 10:37 AM UTC

Thanks Clay... your previouos suggestion, with some tuning did the trick for me. Thanks for your feedback. Regards, Atith

Loader.
Up arrow icon