I am trying to get a default row height without setting it manually, so based on current font for example.
But when I check DefaultRowHeight off of the Override it's -1.
Does it have something to do with RowSizing enum? Currently it's set to AutoFree.
Hi Jiho,
A DefaultRowHeight of -1 means the grid calculates the height of each row based on a number of factors including the RowSizing property, the font, the existence of dropdown buttons in the row and possibly other factors.
So you can't simply get a single value for the DefaultRowHeight, since each row could be a different height.
If you want the height or any individual row, you can use the row's Height property.
I understand that it's calculated. When all my rows are of the same height, it's easy to get the row height by checking the very first row's Height property. But what if there are no rows?
By the way, my need for the height is for custom painting for drag and drop scenario. I need some kind of default height to draw a placeholder.
If there are no rows in the grid, then there's no way to get the height of a row. The grid does not calculate the height until it needs to.
I suppose you could add a test row and then remove it. Or maybe just switch on AllowAddNew with one of the TemplateAddRow styles just so that you have a row to get the height, and then you could immiediately turn it off.
It turns out that TemplateAddRow is always available for my configuration even if it's not showing (index is -1) on the screen. And its Height property does return the actual height. So it looks like I'm set to go. I didn't even have to set AllowAddNew to true for that.
Thanks Mike for the idea!