User (Old forums)MemberOctober 9, 2008 at 1:19 pmPost count: 23064
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:
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
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:
GridControl1.DataRowTemplate.Height = 16
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.
GridControl1.DataSource = DataSet11.Tables( 0 )
GridControl1.DataRowTemplate.FitHeightToEditors = True
gridControl1.DataSource = dataSet11.Tables[ 0 ];
gridControl1.DataRowTemplate.FitHeightToEditors = true;
Imported from legacy forums. Posted by Xceed admin (had 4427 views)
- You must be logged in to reply to this topic.