Automatically Resizing Column Height in GridDataControl
Thank you for contacting Syncfusion support,
We have analyzed your query. You can adjust the ColumnHeader Height based on the content present in the ColumnHeader using ResizeRowToFit method in ModelLoaded event. Please refer the below code snippet.
Code snippet[c#]:
|
void syncgrid_ModelLoaded(object sender, EventArgs e) { this.syncgrid.Model.HeaderStyle.TextWrapping = TextWrapping.Wrap; this.syncgrid.Model.HeaderStyle.TextTrimming = TextTrimming.None; this.syncgrid.Model.ResizeRowsToFit(GridRangeInfo.Row(0), GridResizeToFitOptions.NoShrinkSize); |
You can also set the HeaderRow height using DefaultHeaderRowHeight property. Please refer the below code snippet.
Code snippet[XAML]:
|
<syncfusion:GridDataControl Name="syncgrid" DefaultHeaderRowHeight="70" AutoPopulateColumns="False" ItemsSource="{Binding GDCSource}" NotifyPropertyChanges="True" ShowAddNewRow="False" |
We have prepared the sample based on your requirement and you can download it from below location,
Sample Location: GridDataControl_Sample
Please let us know if you have any other queries,
Regards,
Saravanan.M
Sorry about the inconvenience caused .
In our previous updated sample , we have provided the solution for Header Rows only. You can also wrap the content of GridCell by using the same ResizeRowsToFit() method.You can pass the parameter as GridRangeInfo.Table() instead of rows. We have prepared the sample to achieve your requirement . Please find the sample from the following location ,
Sample : http://www.syncfusion.com/downloads/support/forum/119291/ze/GridDataControlsample__119291-315145167
Please refer the following code example :
XAML :
|
<syncfusion:GridDataVisibleColumn Width="200" HeaderText="Name List Details - Wrapped HeaderText column" MappingName="Name"> <syncfusion:GridDataVisibleColumn.ColumnStyle> <syncfusion:GridDataColumnStyle TextWrapping="Wrap" /> </syncfusion:GridDataVisibleColumn.ColumnStyle> |
C#:
|
void grid_Loaded(object sender, RoutedEventArgs e) { this.grid.Model.ResizeRowsToFit(GridRangeInfo.Table(), GridResizeToFitOptions.NoShrinkSize); |
Please let us know if this solution helps you .
Regards,
Akila R.
We have analyzed your query, you need to call ResizeRowsToFit method in CurrentCellEditingComplete event to achieve your requirement. Please refer the below code snippet.
Code snippet[C#]:
|
void grid_CurrentCellEditingComplete(object sender,SyncfusionRoutedEventArgs args) { this.grid.Model.ResizeRowsToFit(GridRangeInfo.Table(), GridResizeToFitOptions.NoShrinkSize); //throw new NotImplementedException(); |
We have modified the sample based on this and you can download it from following location,
Sample Location: GridDataControlsample_Modified
Please let us know if you have any other queries,
Regards,
Saravanan.M
Thank you for your update. Please let us know if you require any other assistance.
Regards,
Saranya
Hi Ari ,
We are sorry about the inconvenience caused .
We analyzed your query . By default, in GridDataControl the text will wrapped based on the whitespace and special characters (dot(.), separator(,)). So, the input text will not be wrapped if you enter the character without whitespace in GridDataControl . You can overcome this by including appropriate input with whitespace . Here if you would like to achieve your requirement without using whitespace or special character, you can achieve the same requirement with our SfDataGrid control like GridDataControl and its having AutoRowHeight feature to achieve the same in SfDataGrid control.
But when compared to GridDataControl, SfDataGrid has a better performance and flexibility. SfDataGrid assists you to create entirely customizable and highly interactive features used to display and manipulate the huge amount of data. So, we suggest you to use SfDataGrid instead of GridDataControl. Also we have already marked GridDataControl as a classic.
Please refer the following UG link for SfDataGrid.
UG Links: http://help.syncfusion.com/ug/wpf/index.html#!Documents/choosebetweendifferentgrids.htm
http://help.syncfusion.com/ug/wpf/index.html#!Documents/overview19.htm
Also we have prepared the sample for your AutoRowHeight requirement and you can download the sample from following location,
Sample: http://www.syncfusion.com/downloads/support/directtrac/135742/ze/AutoRowHeightDemo-982551612
Please refer the below UG link for AutoRowHeight in SfDataGrid,
http://help.syncfusion.com/ug/wpf/index.html#!Documents/autorowheight.htm
Regards,
Jai Ganesh S
- 12 Replies
- 5 Participants
-
AC Ari Case
- Jun 2, 2015 01:46 PM UTC
- Jun 18, 2015 02:24 AM UTC