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.
Unfortunately, activation email could not send to your email. Please try again.

Header Text Control

Thread ID:

Created:

Updated:

Platform:

Replies:

11971 Mar 18,2004 03:55 PM Mar 22,2004 08:45 AM Windows Forms 13
loading
Tags: GridControl
Tom Hammon
Asked On March 18, 2004 03:55 PM

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

Administrator [Syncfusion]
Replied On March 18, 2004 04:12 PM

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"

Administrator [Syncfusion]
Replied On March 18, 2004 04:46 PM

Thanks That worked.

Rob Panosh
Replied On March 19, 2004 04:35 AM

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" >

Rob Panosh
Replied On March 19, 2004 04:40 AM

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

Administrator [Syncfusion]
Replied On March 19, 2004 05:17 AM

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.)

Administrator [Syncfusion]
Replied On March 19, 2004 07:24 AM

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

Administrator [Syncfusion]
Replied On March 19, 2004 07:37 AM

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.

Administrator [Syncfusion]
Replied On March 19, 2004 07:48 AM

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.

Administrator [Syncfusion]
Replied On March 19, 2004 08:20 AM

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"

Administrator [Syncfusion]
Replied On March 19, 2004 10:27 AM

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" > > >

Administrator [Syncfusion]
Replied On March 19, 2004 10:52 AM

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

Administrator [Syncfusion]
Replied On March 22, 2004 06:25 AM

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

Administrator [Syncfusion]
Replied On March 22, 2004 08:45 AM

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

CONFIRMATION

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.

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.

;