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 | Copy Code |
---|---|
GridControl1.FixedHeaderRows[ 0 ].Height = 16 |
C# | Copy Code |
---|---|
gridControl1.FixedHeaderRows[ 0 ].Height = 16; |
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 | Copy Code |
---|---|
GridControl1.DataRowTemplate.Height = 16 |
C# | Copy Code |
---|---|
gridControl1.DataRowTemplate.Height = 16; |
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 | Copy Code |
---|---|
GridControl1.BeginInit() |
C# | Copy Code |
---|---|
gridControl1.BeginInit(); |
If you are providing data manually, then you can set the values of the DataRowTemplate after you have added columns to the grid.