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

Header Text Control

Is there a way to force a line break in the text of a header cell.

13 Replies

AD Administrator Syncfusion Team March 18, 2004 09:12 PM UTC

In a GridControl, you can use code like: Me.GridControl1(0, 2).Text = "line1" + Environment.NewLine + "line2" For a GridDataBoundGrid, Me.GridDataBoundGrid1.Binder.InternalColumns(1).HeaderText = "line1" + Environment.NewLine + "line2"


AD Administrator Syncfusion Team March 18, 2004 09:46 PM UTC

Thanks That worked.


RP Rob Panosh March 19, 2004 09:35 AM UTC

Clay, I tried the code for the GDBG, Me.GridDataBoundGrid1.Binder.InternalColumns(1).HeaderText = "line1" + Environment.NewLine + "line2", in my form Load and the text doesn''t show in the grid, only show blank cell. I would like to put the text in the the row header (line 0) upper left corner. Thanks, Rob Panosh >In a GridControl, you can use code like: > > Me.GridControl1(0, 2).Text = "line1" + Environment.NewLine + "line2" > > >For a GridDataBoundGrid, > > Me.GridDataBoundGrid1.Binder.InternalColumns(1).HeaderText = "line1" + Environment.NewLine + "line2" >


RP Rob Panosh March 19, 2004 09:40 AM UTC

Clay, Just one more note. The only way I can get this to work is in the "ModelQueryCellInfo" event Sample Code: If e.ColIndex = 0 And e.RowIndex = 0 Then e.Style.CellType = "Header" e.Style.CellValue = "FIND ALL FORMULAS" & Environment.NewLine & "WHERE" e.Style.Font.Bold = True e.Handled = True ENDIF The text will shows but the cell isn''t sized correctly. Is there a way I can tell the cell height to automatically resize? Thanks, Rob


AD Administrator Syncfusion Team March 19, 2004 10:17 AM UTC

Have you explicitly added GridBoundColumns to the grid.GridBoundColumn collection either through code or through the designer? If so, you would use that property instead of the InternalColumns property. Me.GridDataBoundGrid1.GridBoundColumns(1).HeaderText = "line1" + Environment.NewLine + "line2 Another thing to check is whether, from code, you are adding your GridBoundColumns after you have set the DataSource. If so, you may need to call grid.Binder.InitializeColumns to get your change to be reflected in the grid. To size the headers, you would call grid.Model.RowHeights.ResizeToFit(GridRangeInfo.Row(0), GridResizeToFitOptions.IncludeHeaders) You would do this in FormLoad (or wherever) after the datasource has been set (or after you subscribe to QueryCellInfo if you continue to use that. Do not do it in QueryCellInfo though.)


AD Administrator Syncfusion Team March 19, 2004 12:24 PM UTC

Clay, Here is my method that builds my Grid. I cannot get the text the show up in the first row header. Public Sub PopulateConditions() ''Populate the conditions grid. Dim gridColumn As Syncfusion.Windows.Forms.Grid.GridBoundColumn Dim TagValue As New GridQueryConditionsCol_Tag gridColumn = New Syncfusion.Windows.Forms.Grid.GridBoundColumn gridColumn.HeaderText = "Item" gridColumn.StyleInfo.AutoSize = True gridColumn.StyleInfo.Format = "" gridColumn.MappingName = "Description" TagValue.Name = "Item" gridColumn.Tag = TagValue Me.GridDataBaseConditions.GridBoundColumns.Add(gridColumn) Me.GridDataBaseConditions_AddValueColumn(True) Me.GridDataBaseConditions.Model.CoveredRanges.SetCoveredRange(GridRangeInfo.Cells(0I, 0I, 0I, Me.GridDataBaseConditions.GridBoundColumns.Count), True) Me.GridDataBaseConditions.GridBoundColumns(1).HeaderText = "FIND ALL FORMULAS" + Environment.NewLine + "WHERE" ''Me.GridDataBaseConditions.Binder.InitializeColumns() Me.GridDataBaseConditions.DataSource = Me.BusinessObject.Items ''Resize the columns to fit using the first 100 rows. Me.GridDataBaseConditions.Model.ColWidths.ResizeToFit(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Rows(1I, 100I)) ''Me.GridDataBaseConditions.Model.RowHeights.ResizeToFit(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Rows(1I, 100I)) End Sub


AD Administrator Syncfusion Team March 19, 2004 12:37 PM UTC

You are covering the header row starting at cell 0,0. So, the col 1 header cell is covered. I suspect that is why you cannot see it. Try starting your covered row from 0,1 to check if this is why.


AD Administrator Syncfusion Team March 19, 2004 12:48 PM UTC

Clay, That is correct. I want to cover cell 0,0 and I want the text to be in column 0 ( row 0 ). I changed my code to: Me.GridDataBaseConditions.GridBoundColumns(0).HeaderText = "FIND ALL FORMULAS" + Environment.NewLine + "WHERE" and I still don''t get any text at 0,0 Rob >You are covering the header row starting at cell 0,0. So, the col 1 header cell is covered. I suspect that is why you cannot see it. Try starting your covered row from 0,1 to check if this is why.


AD Administrator Syncfusion Team March 19, 2004 01:20 PM UTC

The reason is cell 0,0 does not belong to any column from your datasource. It is on top of the row headers. GridBoundColumns(0).Headertext is the teext that sits above teh first column from your datasource. It is not the text that sits above the row header column. Try this. Me.GridDataBaseConditions(0,0).Text = "FIND ALL FORMULAS" + Environment.NewLine + "WHERE"


AD Administrator Syncfusion Team March 19, 2004 03:27 PM UTC

Clay, Sorry that didn''t work. Rob >The reason is cell 0,0 does not belong to any column from your datasource. It is on top of the row headers. GridBoundColumns(0).Headertext is the teext that sits above teh first column from your datasource. It is not the text that sits above the row header column. > >Try this. > >Me.GridDataBaseConditions(0,0).Text = "FIND ALL FORMULAS" + Environment.NewLine + "WHERE" > > >


AD Administrator Syncfusion Team March 19, 2004 03:52 PM UTC

I am not sure if it serves your needs, but here is a sample showing what I have been suggesting. If something like the sample does not serve your needs, then I think you would have to handle events to try to do what you want. forumsample_1137.zip


AD Administrator Syncfusion Team March 22, 2004 11:25 AM UTC

Clay, I made slight modifications to your sample in the form1_load, see below, and the column is not painting right. Rob Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dt As New DataTable("MyTable") Dim nCols As Integer = 4 Dim nRows As Integer = 10 Dim i As Integer Dim j As Integer For i = 0 To nCols - 1 dt.Columns.Add(New DataColumn(String.Format("Col{0}", i))) Next For i = 0 To nRows - 1 Dim dr As DataRow = dt.NewRow() For j = 0 To nCols - 1 dr(j) = String.Format("row{0} col{1}", i, j) Next dt.Rows.Add(dr) Next Me.GridDataBoundGrid1.DataSource = dt ''Me.GridDataBoundGrid1.Binder.InternalColumns(0).HeaderText = "Long line1" + Environment.NewLine + "Long line2" Me.GridDataBoundGrid1.Model.CoveredRanges.Add(GridRangeInfo.Cells(0, 0, 0, Me.GridDataBoundGrid1.Model.ColCount)) Me.GridDataBoundGrid1(0, 0).Text = "This is a test line that is very long" + Environment.NewLine + "line2" Me.GridDataBoundGrid1.Model.RowHeights(0) = 35 '' Me.GridDataBoundGrid1.BaseStylesMap("Header").StyleInfo.CellType = "Static" '' Me.GridDataBoundGrid1.BaseStylesMap("Column Header").StyleInfo.CellType = "Static" End Sub


AD Administrator Syncfusion Team March 22, 2004 01:45 PM UTC

You will not be able to include 0,0 as part of a covered top row. The reason is that cell 0,0 is frozen both columnwise and row wise. So, if you include it as part of covered row, then part of the covered cell(everything except 0,0) is scrollable (horizontally), but 0,0 is not scrollable horizontally. And I this is causing the frozen cell border to come and go (which is teh only painting problem I see). You will see the heade text from DataColumnzero as that is covered by teh covered cell. In a covered cell, the only text you see is from the top-left cell (0,0) in your code. Every other cell is covered. Now if you want the appearance of a covered cell starting at the very left column, then I think you will have to hide the row header column in the grid, and make the first column be a row header. Then covering a cell starting at 0,1 will make the covered cell appear to start on the lefy. (You would still not see any text from any cell other than cell 1,0). Here is a little code. Next Me.GridDataBoundGrid1.DataSource = dt Me.GridDataBoundGrid1.Model.Cols.FrozenCount = 1 Me.GridDataBoundGrid1.Model.Cols.HeaderCount = 1 Me.GridDataBoundGrid1.Model.Cols.Hidden(0) = True Me.GridDataBoundGrid1.Model.ColWidths(1) = 20 Me.GridDataBoundGrid1.Model.ColCount += 1 ''adjust for extra header column Me.GridDataBoundGrid1.Model.CoveredRanges.Add(GridRangeInfo.Cells(0, 1, 0, Me.GridDataBoundGrid1.Model.ColCount)) Me.GridDataBoundGrid1(0, 1).Text = "This is a test line that is very long" + Environment.NewLine + "line2" Me.GridDataBoundGrid1.Model.RowHeights(0) = 35 End Sub

Loader.
Up arrow icon