By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,534 Members | 943 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,534 IT Pros & Developers. It's quick & easy.

Dynamic Gridview Header Wrap Text

P: 14
Hi I have a Gridview, where I create dynamic headers on RowCreated. Thats all fine, but the text in the header column doesn't wrap. This makes the columns way to wide. I have tried cell.wrap = true which does nothing. Any help would be appreciated.

Below is the RowCreated code.

Expand|Select|Wrap|Line Numbers
  1.        Dim gvrHeaderGridview3 As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert)
  2.                 For colAdd = 0 To 5
  3.                     Dim tblCellAdd3 As New TableCell
  4.                     tblCellAdd3.Wrap = True
  5.                     If colAdd = 0 Then
  6.                         tblCellAdd3.Text = "CPI is used for Baseline for Real Estate Cycle"
  7.                         tblCellAdd3.ColumnSpan = 2
  8.                     ElseIf colAdd = 1 Then
  9.                         tblCellAdd3.Text = "Cycle Duration (4-15 Yrs)"
  10.                         tblCellAdd3.ColumnSpan = 1
  11.                         tblCellAdd3.RowSpan = 3
  12.                     ElseIf colAdd = 2 Then
  13.                         tblCellAdd3.Text = "1st Peak Year Closest" & " " & "to Before / After"
  14.                         tblCellAdd3.Wrap = True
  15.                         tblCellAdd3.Width = 100
  16.                         tblCellAdd3.ColumnSpan = 1
  17.                         tblCellAdd3.RowSpan = 3
  18.                     ElseIf colAdd = 3 Then
  19.                         tblCellAdd3.Text = "Annual Growth in Baseline Up-Cycle"
  20.                         tblCellAdd3.Wrap = True
  21.                         tblCellAdd3.ColumnSpan = 1
  22.                         tblCellAdd3.RowSpan = 3
  23.                     ElseIf colAdd = 4 Then
  24.                         tblCellAdd3.Text = "Annual Growth in Baseline Down-Cycle Deflation"
  25.                         tblCellAdd3.Wrap = True
  26.                         tblCellAdd3.ColumnSpan = 1
  27.                         tblCellAdd3.RowSpan = 3
  28.                     ElseIf colAdd = 5 Then
  29.                         tblCellAdd3.Text = "Annual Slow Down in Trough Deflation"
  30.                         tblCellAdd3.Wrap = True
  31.                         tblCellAdd3.ColumnSpan = 1
  32.                         tblCellAdd3.RowSpan = 3
  33.                     End If
  34.  
  35.                     tblCellAdd3.HorizontalAlign = HorizontalAlign.Left
  36.                     tblCellAdd3.BackColor = colHexDarkBlue
  37.                     tblCellAdd3.BorderStyle = BorderStyle.Outset
  38.                     tblCellAdd3.BorderColor = colHexOrange
  39.                     tblCellAdd3.ForeColor = Drawing.Color.White
  40.                     tblCellAdd3.Font.Bold = True
  41.                     gvrHeaderGridview3.Cells.Add(tblCellAdd3)
  42.                 Next
  43.  
  44.                 CType(gvEconCyclesNormal.Controls(0), Table).Rows.AddAt(0, gvrHeaderGridview3)
  45.  
May 6 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.