Disable multiline in GridTextColumn

Hello,

I am still learning how to use all features of SFDataGrid. At the moment I have bound sample data (DataTable) from an SQL Table to an SFDataGrid.

There is one column of datatype varchar(max), containing multiline text. The line breaker shows like "\n" when debugging. The SFDataGrid displays this text like multiline text. Please refer to the image I attached. I try to display the text only as single line, because it is too long for the cell. The complete text shows up in the ToolTip.

How is it possible to avoid the multiline text? I tried everything I could find, for example set "AllowMultiline" and "AllowWrap" to false.

Thanks for any tips!
Michael

Attachment: MultilineText_4fbe63f0.zip

7 Replies

SS Susmitha Sundar Syncfusion Team June 16, 2020 10:15 AM UTC

Hi Michael, 
 
Thank you for using Syncfusion controls. 

You can disable the TextWrapping of GridTextColumn by using AllowTextWrapping as false.  

sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "Destination", AllowTextWrapping = false }); 
 

Please let us know if you need further assistance on this. 

Regards, 
Susmitha S 



MW Michael Witzik June 16, 2020 12:22 PM UTC

Hello Susmitha,

thank you for your answer.

I´m sorry, but setting the "AllowTextWrapping" property to false, didn´t help. Please see attached image. I am using AutoGenerateColumns.

Is there an other reason why this doesn´t work? The cell type shows as TextBox, is this different from "GridTextColumn"?

Thank you!
Michael

Attachment: AllowTextWrapFalse_36813e1.zip


SS Susmitha Sundar Syncfusion Team June 17, 2020 11:41 AM UTC

Hi Michael, 
 
Thank you for the update. 
 
Can you please share your column settings and DataSource settings for SfDataGrid? 
 
It will be helpful for us to check on it and provide you the solution at the earliest.   
 
Regards, 
Susmitha S 



MW Michael Witzik June 17, 2020 12:21 PM UTC

Hello Susmitha,

I am using very simple code:

DataTable tabTest = new DataTable();
SqlCommand sqlCom = new SqlCommand(@"SELECT * From TestTab", sqlConn);
SqlDataAdapter sqlDA = new SqlDataAdapter(sqlCom);
sqlDA.Fill(tabTest );

gridTest.DataSource = tabTest;

foreach (var Spalte in gridTest.Columns)
{
    Spalte.ImmediateUpdateColumnFilter = true;
    Spalte.FilterRowCondition = Syncfusion.WinForms.DataGrid.Enums.FilterRowCondition.Contains;
    Spalte.ShowToolTip = true;
}

The problematic column has datatype "varchar(max)" in MS SQL Server. It gets filled with text from a multiline textbox via an SQL Update command.

I tried to remove the line break character in the column directly in the underlying DataTable. But then the tooltip of the column also shows no more line breaks.

Thank you.
Michael


SS Susmitha Sundar Syncfusion Team June 19, 2020 01:46 PM UTC

Hi Michael, 
  
We have created a new incident under your Direct trac account. We suggest you follow up with the incident for further updates. Please log in using the below link.  
  
  
Regards, 
Susmitha S 



LS Lloyd Sheen May 19, 2022 07:32 PM UTC

Property  AllowTextWrapping  does not exist in the 

GridTextColumn so most of this post is garbage.



VS Vijayarasan Sivanandham Syncfusion Team May 20, 2022 02:35 PM UTC

Hi Lloyd Sheen,

The AllowTextWrapping property is defined in GridColumnBase class. Because AllowTextWrapping property is used for different types of columns. So, we have maintained commonly used properties in the base class of the grid column. The GridTextColumn is derived from the GridColumnBase. So, we can use the AllowTextWrapping property in by GridTextColumn.

API Link: https://help.syncfusion.com/cr/windowsforms/Syncfusion.WinForms.DataGrid.GridColumnBase.html#Syncfusion_WinForms_DataGrid_GridColumnBase_AllowTextWrapping

https://help.syncfusion.com/cr/windowsforms/Syncfusion.WinForms.DataGrid.GridTextColumn.html

UG Link: https://help.syncfusion.com/windowsforms/datagrid/columns

Please find the sample in the attachment and let us know if you have any concerns in this.


Regards,

Vijayarasan S


Attachment: SfDataGriddemo_668af742.zip

Loader.
Up arrow icon