Posted 17 October 2022, 7:11 am EST
I’m trying to get the Rectangle of a given column caption. Currently, I’m using the GetCellBounds method from the Split class and that mostly works. The call looks like this:
Rectangle l_colRect = MyGrid.Splits[l_splitIdx].GetCellBounds(0, l_colIdx);
From there, I recalculate the Y coordinate based on caption heights, etc. However, this makes it depend on there being data present. If there isn’t, an exception gets thrown because there is no row 0.
I suppose I could calculate the X coordinate and the width of the desired rectangle based on cycling through the DisplayColumns in the split and adding the widths and also taking into account the horizontal scrollbar offset. But, isn’t there already a method that would allow me to get it without depending on data being in the grid?