Auto Wrap text in flexgrid

Posted by: c_lynch on 9 September 2017, 8:21 am EST

  • Posted 9 September 2017, 8:21 am EST

    Hi,
    I have the following flexgrid:

    [code] <FlexGrid:C1FlexGrid
    Grid.Row="1"
    x:Name="_flex"
    SelectionMode="Row"
    AutoGenerateColumns="False"
    Margin="20 10 20 20"
    HeadersVisibility="Column"
    HeaderGridLinesBrush="#80ffffff"
    ColumnHeaderForeground="Orange"
    SelectionBackground="Orange"
    SelectionForeground="Black"
    CursorBackground="Orange"
    CursorForeground="Black" Xaml:C1NagScreen.Nag="True"
    >
    <FlexGrid:C1FlexGrid.Columns>
    <FlexGrid:Column Binding="{Binding Id}" Width="*"/>
    <FlexGrid:Column Binding="{Binding LogType}" Width="*"/>
    <FlexGrid:Column Binding="{Binding Text}" Width="4*"/>
    <FlexGrid:Column Binding="{Binding Email}" Width="*"/>
    <FlexGrid:Column Binding="{Binding created_at}" Width="*"/>
    </FlexGrid:C1FlexGrid.Columns>
    </FlexGrid:C1FlexGrid>[/code]



    The column {Binding Text} contains a lot of textual information and unfortunatley not all the info is being shown as the row does not autoresize itself to fit the content.

    I did try _flex.AutoSizeRows(0, _flex.Cells.Rows.Count-1, 100,true); in the .cs file but it only seems to make the rows height larger but not actually wrap the content. (see the attached screenshot)

    How can i enable the rows to autosize/autowrap to the content?

    Thanks for any help you can provide
    Chris

  • Replied 9 September 2017, 8:21 am EST



    <FlexGrid:C1FlexGrid
    Grid.Row="1"
    x:Name="_flex"
    SelectionMode="Row"
    AutoGenerateColumns="False"
    Margin="20 10 20 20"
    HeadersVisibility="Column"
    HeaderGridLinesBrush="#80ffffff"
    ColumnHeaderForeground="Orange"
    SelectionBackground="Orange"
    SelectionForeground="Black"
    CursorBackground="Orange"
    CursorForeground="Black" Xaml:C1NagScreen.Nag="True"
    >
    <FlexGrid:C1FlexGrid.Columns>
    <FlexGrid:Column Binding="{Binding Id}" Width="*"/>
    <FlexGrid:Column Binding="{Binding LogType}" Width="*"/>
    <FlexGrid:Column Binding="{Binding Text}" Width="4*"/>
    <FlexGrid:Column Binding="{Binding Email}" Width="*"/>
    <FlexGrid:Column Binding="{Binding created_at}" Width="*"/>
    </FlexGrid:C1FlexGrid.Columns>
    </FlexGrid:C1FlexGrid>
  • Replied 9 September 2017, 8:21 am EST

    Hello,

    You need to set TextWrapping for all or particular column to true for that matter as given below:-

    _flex.Columns[string column_Name].CellStyle.TextWrapping = true;

    Hope it helps.

    Thanks,
    Reeva
  • Marked as Answer

    Replied 9 September 2017, 8:21 am EST

    Reeva,
    Thank-you for the reply, I appreciate the help.

    Unfortunately your suggestion did not seem to work for me (null reference for CellStyle), I am new to C# and xaml so its possible I did something wrong.

    But using your suggestion I found the following did work for me:
     
    var wrapStyle = new C1.Xaml.FlexGrid.CellStyle();

    wrapStyle.TextWrapping = true;

    _flex.Columns["Text"].CellStyle = wrapStyle;
  • Replied 9 September 2017, 8:21 am EST

    Hello,

    Glad to know your issue is resolved.

    Thanks for contacting ComponentOne.

    Regards,
    Reeva
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels