How do I make all column headers have text wrapping?

6 posts, 0 answers
  1. Joshua
    Joshua avatar
    29 posts
    Member since:
    Mar 2011

    Posted 05 May 2011 Link to this post

    How do I make all column headers have text wrapping?
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 05 May 2011 Link to this post

    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
  3. Joshua
    Joshua avatar
    29 posts
    Member since:
    Mar 2011

    Posted 05 May 2011 Link to this post

    If I have autogenerated columns how do I achieve this? Thanks.
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 05 May 2011 Link to this post

    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
  5. Jesse
    Jesse avatar
    6 posts
    Member since:
    Jan 2008

    Posted 30 Apr 2015 in reply to Maya Link to this post

    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?

     

     

  6. Stefan
    Admin
    Stefan avatar
    1073 posts

    Posted 05 May 2015 Link to this post

    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.

     
Back to Top