Home Forums WinForms controls Xceed Grid for WinForms How to change the height of rows

Viewing 1 post (of 1 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17810 |

    The height of each row in the grid can be changed in various ways:

    • You can change the height of each row individually using the row’s Height property.
    • You can change the height of each DataRow using the Height property of the grid’s DataRowTemplate.
    • You can retrieve the height necessary to display all the content of the row or just one line of content using the GetFittedHeight method.
    • You can adjust the height of a row to fit its editors using the FitHeightToEditors property.
    • You can change the way the height of the row is adjusted using the AutoHeightMode property.

    If you want to change the height of a specific row in the grid to a predetermined value, you simply need to set that row’s Height property. If you want to set the height of all the DataRows in the grid, you can set the Height property of the DataRowTemplate to the desired value. The same goes with the AutoHeightMode and FitHeightToEditors property as well as the GetFittedHeight method.

    To change the height of a specific row (using the various methods mentioned above) you can use the following code:

    VB.NET

    GridControl1.FixedHeaderRows[ 0 ].Height = 16
    GridControl1.FixedFooterRows[ 1 ].AutoHeightMode = AutoHeightMode.AllContent

    GridControl1.Groups[ 0 ].HeaderRows[ 0 ].Height = gridControl1.FixedHeaderRows[ 0 ].GetFittedHeight( AutoHeightMode.AllContent )
    GridControl1.DataRows[ 0 ].FitHeightToEditors = True  

    C#

    gridControl1.FixedHeaderRows[ 0 ].Height = 16;
    gridControl1.FixedFooterRows[ 1 ].AutoHeightMode = AutoHeightMode.AllContent;

    gridControl1.Groups[ 0 ].HeaderRows[ 0 ].Height = gridControl1.FixedHeaderRows[ 0 ].GetFittedHeight( AutoHeightMode.AllContent );
    gridControl1.DataRows[ 0 ].FitHeightToEditors = true;
     

    To change the height of every DataRow in the grid, the most efficient way is to use the DataRowTemplate. Of course you can use any one of the properties or methods mentioned above! For example:

    VB.NET

    GridControl1.DataRowTemplate.Height = 16

    C#

    gridControl1.DataRowTemplate.Height = 16;

    If the DataRowTemplate changes while the DataSource property is set, the changes will not automatically be reflected in the grid. In order for the modifications to be applied, the data source must be reassigned to the DataSource property. If you want to set various properties of the DataRowTemplate when you populate your grid (set the DataSource property), then this will need to be done between calls to the grid’s BeginInit and EndInit methods.

    VB.NET

    GridControl1.BeginInit()
    GridControl1.DataSource = DataSet11.Tables( 0 )
    GridControl1.DataRowTemplate.FitHeightToEditors = True
    GridControl1.EndInit()

    C#

    gridControl1.BeginInit();
    gridControl1.DataSource = dataSet11.Tables[ 0 ];
    gridControl1.DataRowTemplate.FitHeightToEditors = true;
    gridControl1.EndInit();

    Imported from legacy forums. Posted by Xceed admin (had 4427 views)

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.