vb.netcomponentonec1flexgrid

How to resize row height in C1FlexGrid?


I need to auto resize row height in a C1FlexGrid. I need to make it work using AutoSizeRow but it does not change the row height. I tested it by setting height and it works. Why is AutoSizeRow not working?

For i As Integer = 0 To fgrid.Rows.Count - 1

    'Setting the height explicitly changes the row height    
    fgrid.Rows(i).Height = 32

    'But AutoSizeRow() does not change the row height
     fgrid.AutoSizeRow(i)
Next i

Solution

  • Please note that the AutoSizeRow method works when there is any data filled in the grid's row. If there isn't any data, AutoSizeRow would simply wont work. The same thing is happening in you snippet. Since there is no data in the row, fgrid.AutoResize(i) is useless. Try replacing your snippet with the following, and you would understand how AutoSizeRow works:

        For i As Integer = 0 To fgrid.Rows.Count - 1
            'Fill data in the cell
            fgrid.Rows(i)(1) = "This is sample text"
    
            'Setting the height explicitly changes the row height    
            fgrid.Rows(i).Height = 32
    
            'AutoSizeRow() is changing the row height now
            fgrid.AutoSizeRow(i)
        Next i