我需要在C1FlexGrid中自动调整行高。我需要使用AutoSizeRow使其工作,但它不会更改行的高度。我通过设置高度来测试它,它很有效。AutoSizeRow为什么不起作用?
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
请注意,AutoSizeRow方法在网格的行中填充任何数据时都有效。如果没有任何数据,AutoSizeRow将无法工作。同样的事情也发生在你的片段中。由于行中没有数据,fgrid.AutoResize(i)是无用的。试着用下面的代码段替换你的代码段,你就会明白AutoSizeRow是如何工作的:
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