Automatically resize C1TrueDBGrid row based on content?

Posted by: marc.brown on 20 March 2018, 5:27 am EST

    • Post Options:
    • Link

    Posted 20 March 2018, 5:27 am EST

    Is it possible to have C1TrueDBGrid automatically resize rows based on the contents of a cell or cells? It’s a simple thing to do with the WPF C1DataGrid (RowHeight=“Auto”) but I’ve not found a way to do it with the WinForms C1TrueDBGrid.

  • Posted 20 March 2018, 6:01 pm EST

    Hi Marc!

    Currently, there seems to be some issue with it. We are looking into this matter, and will notify you as soon as it is resolved [Internal Id : 314656].

    Thanks,

    Meenakshi

  • Posted 16 May 2018, 2:27 pm EST

    Hello!

    Sorry for the delay. Here is the solution to your problem : In Form’s Load event, you need to resize rows once.

    c1TrueDBGrid1.AllowRowSizing = RowSizingEnum.IndividualRows;
    foreach (C1DisplayColumn col in c1TrueDBGrid1.Splits[0].DisplayColumns)
            col.Style.Wrap = TextWrapping.Wrap;
    
    for(int r = 0; r < c1TrueDBGrid1.Splits[0].Rows.Count; r++)
    {
            c1TrueDBGrid1.Splits[0].Rows[r].AutoSize();
    }
    

    And then, in AfterColEdit event of grid, you can use AutoSize method, as given below.

    private void C1TrueDBGrid1_AfterColEdit(object sender, ColEventArgs e)
    {
            c1TrueDBGrid1.Splits[0].Rows[c1TrueDBGrid1.Row].AutoSize();            
    }
    

    Best regards,

    Meenakshi

Need extra support?

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

Learn More

Forum Channels