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.
Unfortunately, activation email could not send to your email. Please try again.

Multiline Textbox

Thread ID:

Created:

Updated:

Platform:

Replies:

129906 Apr 9,2017 01:32 PM Apr 11,2017 01:05 AM WPF 3
loading
Tags: SfDataGrid
Forstmeier Peter
Asked On April 9, 2017 01:32 PM

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


Muthukumar Kalyanasundaram [Syncfusion]
Replied On April 10, 2017 03:17 AM

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 


Forstmeier Peter
Replied On April 10, 2017 02:09 PM

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

Muthukumar Kalyanasundaram [Syncfusion]
Replied On April 11, 2017 01:05 AM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;