Wrap Text Row Cell

 

I did the same by visiting the link you mentioned below...But it didn't work for me..Please help me on this!
https://help.syncfusion.com/windowsforms/datagrid/rowheightcustomization#fit-row-height-based-on-its-content

and I want only the "ReportType" column to be wrap text and the date data to drop down

this my code:

        void sfDataGrid_QueryRowHeight(object sender, QueryRowHeightEventArgs e)

        {

            RowAutoFitOptions autoFitOptions = new RowAutoFitOptions();

            int autoHeight;

            if (this.SfGrid.AutoSizeController.GetAutoRowHeight(e.RowIndex, autoFitOptions, out autoHeight))

            {

                if (autoHeight > 35)

                {

                    e.Height = autoHeight;

                    e.Handled = true;

                }

            }

        }

I hope I was able to explain...Thank you for your attention.


Attachment: wraptext_6016df44.rar

3 Replies

SG Santhosh Govindasamy Syncfusion Team September 19, 2023 05:13 PM UTC

Hi Murad Jafarov,

To achieve your goal, you need to properly set the value of the AllowTextWrapping property for the columns based on your requirement. AllowTextWrapping determines whether the text in a cell should be wrapped or not when the length of the text exceeds the size of the cell.

 

In your case, you need to set the AllowTextWrapping property for the "ReportType" column.

 

To set the value, use the following code:

(sfDataGrid1.Columns["ReportType"] as GridTextColumn).AllowTextWrapping = true;

 (sfDataGrid1.Columns["ProductName"] as GridTextColumn).AllowTextWrapping = true;

 (sfDataGrid1.Columns["Designation"] as GridTextColumn).AllowTextWrapping = true;


For your reference, I attach the sample.


Regards,
Santhosh.G


Attachment: CS_2db5350a.zip


MJ Murad Jafarov September 21, 2023 07:58 AM UTC

this helped me thank you very much



CM Chidanand Murugaiah Syncfusion Team September 25, 2023 07:13 AM UTC

Hi Murad Jafarov,


Glad that your issue is resolved!! Please let us know if you require any additional assistance. We are happy to help you.


Regards,

Chidanand M.



Loader.
Up arrow icon