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
close icon

Suppress enter key with griddatacontrol?

Hi,

I want to suppress the default enter key behavior. From what I can tell, the regular gridcontrol has a WantEnterKey property that can be set to false, but how can I accomplish the same thing with a GridDataControl?


-Sören

3 Replies

GA Gobinath A Syncfusion Team May 7, 2013 02:43 PM UTC

HI Sören,

Thanks for using Syncfusion products.

We have analyzed your query and In GridDataControl don’t have the WantEnterKey property but if you want to suppress the enter key then you can achieve your requirement by using PreviewKeyDown event as below the code snippet.


Code snippet[C#]:

 

this.SyncGrid.PreviewKeyDown += new KeyEventHandler(SyncGrid_PreviewKeyDown);

 

 

void SyncGrid_PreviewKeyDown(object sender, KeyEventArgs e)

        {

            if (Key.Enter == e.Key)

            {

                e.Handled = true;

            }

        }


 

Please let us know if you have any queries.

 

Regards,

Gobinath A.

 



SH Sören Höglund May 10, 2013 12:45 PM UTC

My specific use case was a bit more complex: I have a textbox in a detail view that accepts new lines, so I can't just mark the event as handled.

Manually adding newlines to the control using the preview key event is how I ended up handling it, and that works, but it's not exactly a neat solution.


GA Gobinath A Syncfusion Team June 3, 2013 11:42 AM UTC

Hi Sören,

 

Sorry for the delay in getting back to you.

 

We have analyzed your query and you can achieve your requirement by using below the code snippet for multiline option.

 

Code snippet[XAML]:

 

<syncfusion:GridDataVisibleColumn MappingName="Quantity">

    <syncfusion:GridDataVisibleColumn.ColumnStyle>

        <syncfusion:GridDataColumnStyle AcceptsReturn="True"/>

     </syncfusion:GridDataVisibleColumn.ColumnStyle>

</syncfusion:GridDataVisibleColumn>

 

 

We have prepared sample based on your requirement and please find the sample under the following location.

 

Sample: GridDataControl.zip

 

Please let us know if you have any queries.

 

Regards,

 

Gobinath A.


Loader.
Live Chat Icon For mobile
Up arrow icon