We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Multiline Textbox

Hi all togehter,

i have the following XAML in my Grid:

<Syncfusion:GridTemplateColumn HeaderText="Beschreibung" TextWrapping="Wrap"  MappingName="Description">
                    
                    <Syncfusion:GridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Description}"  TextWrapping="Wrap" />
                        </DataTemplate>
                    </Syncfusion:GridTemplateColumn.CellTemplate>
                    
                    <Syncfusion:GridTemplateColumn.EditTemplate>
                        <DataTemplate>
                            
                            <TextBox Text="{Binding Description, Mode=TwoWay}"
                                   ScrollViewer.VerticalScrollBarVisibility="Auto"
                                     Syncfusion:FocusManagerHelper.FocusedElement="True"
                                      AcceptsReturn="True"
                                     TextWrapping="Wrap"
                            />
                        
                        </DataTemplate>
                    </Syncfusion:GridTemplateColumn.EditTemplate>
                </Syncfusion:GridTemplateColumn>


I calculate the RowHight with:

QueryRowHeight="DataGrid_QueryRowHeight"
CurrentCellEndEdit="DataGrid_CurrentCellEndEdit"

Code is from google and the forum here..

Display the Multilie Text works as expected.

What i need to have is:

A editable textbox, with the possiblity to add new lines with the <CR> Key.

Thanks in advance

Peter


3 Replies

MK Muthukumar Kalyanasundaram Syncfusion Team April 10, 2017 07:17 AM UTC

Hi Peter, 
 
Thank you for contacting Syncfusion support. 
 
We have analyzed your query. You can achieve your requirement by overriding the ProcessKeyDown event in GridCellSelectionController class. By default, in the SfDataGrid on pressing the Enter key, the currentcell is moved to the next row, you can overcome this problem by setting KeyEventArgs.Handled as false in ProcessKeyDown event. For your reference, we have added the code snippet and sample in below location. Could you please refer to it. 
 
Code Snippet: 
 
this.datagrid.SelectionController = new GridCellSelectionControllerExt(datagrid); 
 
public class GridCellSelectionControllerExt : GridCellSelectionController 
{ 
    public GridCellSelectionControllerExt(SfDataGrid dataGrid) 
    : base(dataGrid) 
    { 
 
    } 
    protected override void ProcessKeyDown(KeyEventArgs args) 
    { 
        if (args.Key == Key.Enter) 
        { 
            args.Handled = false; 
            return; 
        } 
        base.ProcessKeyDown(args); 
    } 
} 
 
 
 
 
 
Please let us know if you have any query. 
 
Regards, 
Muthukumar K 



FP Forstmeier Peter April 10, 2017 06:09 PM UTC

Hi and thanks a lot.
Your example works perfectly.
Thanks
Peter


MK Muthukumar Kalyanasundaram Syncfusion Team April 11, 2017 05:05 AM UTC

Hi Peter, 
 
You are welcome. Please let us know if you need any other assistance. 
 
Regards, 
Muthukumar K 


Loader.
Live Chat Icon For mobile
Up arrow icon