Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1467
TextVAlign
posted

In the InitializeLayout event of a grid, I set the e.Layout.Bands[bandName].Columns[columnName].Width of each column, and I set

            e.Layout.Override.RowSizing = RowSizing.AutoFree;
            e.Layout.Override.CellMultiLine = DefaultableBoolean.True;

The text automatically wraps if it is not wide enough to fit in a column, and the row height adjusts automatically. However the text in all cells is aligned to the top of the cell. I think the grid would look a lot better if all text were centered vertically instead.

I have tried setting

            e.Layout.Override.CellAppearance.TextVAlign = VAlign.Middle;

and several variants of this, but I have been unable to find a way to make the text in all cells center vertically, although the text in some of them, for example in the Date columns, does do so. There must be a way, but what is it?

 

  • 469350
    Verified Answer
    Offline posted

    When a cell in the grid goes into edit mode, the grid displays an Inbox TextBox over the cell to allow you to edit. The inbox TextBox control does not support vertically aligning the text when multiline is set to true. So the grid can't support this, either. 

    If your cell is not editable and you want to center it when it is not in edit mode, you can do that with a DrawFilter. Let me know if that's the case and I will see if I can dig up the DrawFilter code for you.