2

I need to be able to adjust row height of C1FlexGird based on the current font size chosen for the grid. I see there are AutoSizeCols and AutoSizeRows methods but they work only if applied after data loads into the grid. For some reasons/limitations, I can't go with this approach.

So I am trying to see if there is any property on the grid to set the default row height before data loads into the grid.

Thanks for any help!

Nilay Vishwakarma
  • 3,105
  • 1
  • 27
  • 48
Jyina
  • 2,530
  • 9
  • 42
  • 80

1 Answers1

1

You may use the following snippet to accomplish your requirements:

Public Sub New()
    InitializeComponent()

    'Update these according to your computation
    Dim FixedRowHeight As Int32 = 40
    Dim NormalRowHeight As Int32 = 30

    For Each row As C1.Win.C1FlexGrid.Row In C1FlexGrid1.Rows
        If row.Index < C1FlexGrid1.Rows.Fixed Then
            'For Fixed rows
            row.HeightDisplay = FixedRowHeight
        Else
            'For other rows
            row.HeightDisplay = NormalRowHeight
        End If
    Next
End Sub
Nilay Vishwakarma
  • 3,105
  • 1
  • 27
  • 48
  • Thank you for your input. I am wondering if it applies the row height after the data loads into the grid. I see we are looping through the Rows collection here and setting the HeightDisplay but in my case by the time I set the row height there wont be any data in the grid at that point. The loading of the data happens after I set the row height. But I will try your code now. Thank you! – Jyina Oct 15 '14 at 14:17
  • @Jyina HeightDisplay is not dependent on content of the row. And unless you have set AutoSizeRow to true on edit, it wont effect your use case – Nilay Vishwakarma Oct 15 '14 at 14:38
  • Please correct me if I am wrong. Since the HeightDisplay is not dependent on the content, we don't need to call AutoSizeRow. But I need to have the rows already added to the grid even if the content does not load by that point because we are setting the HeightDisplay by looping through the rows that are already added to the grid. Correct? Thanks for your help! – Jyina Oct 15 '14 at 15:06
  • Specifically for the above routine....yes. Your routine may change according to the the grid. How you are adding rows? Is you grid bound or unbound? – Nilay Vishwakarma Oct 15 '14 at 15:53