This is a migrated thread and some comments may be shown as answers.

How do I make all column headers have text wrapping?

5 Answers 58 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Joshua
Top achievements
Rank 1
Joshua asked on 05 May 2011, 06:38 AM
How do I make all column headers have text wrapping?

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 05 May 2011, 06:42 AM
Hi Joshua,

You may take a look at this article for a reference.
 

All the best,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Joshua
Top achievements
Rank 1
answered on 05 May 2011, 07:17 AM
If I have autogenerated columns how do I achieve this? Thanks.
0
Maya
Telerik team
answered on 05 May 2011, 01:26 PM
Hi Joshua,

You may define an implicit style targeting TextBlock as follows:

<Window.Resources>     
    <Style TargetType="TextBlock">
        <Setter Property="TextWrapping" Value="Wrap"/>
    </Style>
</Window.Resources>

Thus the TextWrapping setting will be applied to all your columns without the need of explicitly setting it.
 

Regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jesse
Top achievements
Rank 1
answered on 30 Apr 2015, 04:31 PM

Maya -

How would you accomplish this is code-behind?

here is what I tried:

Dim col As GridViewBoundColumnBase
col = New GridViewDataColumn()
With col
    .Name = "AFEYear"
    .DataMemberBinding = New Binding("AFEYear")
    .TextAlignment = TextAlignment.Left
    .Width = 50
    .IsReadOnly = True
    .Header.textblock.text = "AFE Year"    'Error here
    .Header.textblock.textwrapping = "Wrap"   'Error here
End With
.Columns.Add(col)

"Textblock"  is not a member of Header.

 

Do you have an example of the right way to manipulate the column header textblock in code?

 

 

0
Stefan
Telerik team
answered on 05 May 2015, 08:59 AM
Hello Jesse,

Please note, that for achieving this you need to instantiate the TextBlock by yourself, as in the code snippet below:
Dim column As New GridViewDataColumn() With { _
    Key .DataMemberBinding = New Binding("Name"), _
    Key .Width = 80 _
}
Dim tb As New TextBlock()
tb.Text = "LOOOOOOOOOOOOOOOOOOONG"
tb.TextWrapping = TextWrapping.Wrap
 
column.Header = tb
 
Me.clubsGrid.Columns.Add(column)

I hope this makes sense.

Best Regards,
Stefan
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
GridView
Asked by
Joshua
Top achievements
Rank 1
Answers by
Maya
Telerik team
Joshua
Top achievements
Rank 1
Jesse
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or