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.

How to automatically set grid cells to edit mode

Thread ID:

Created:

Updated:

Platform:

Replies:

124098 May 17,2016 01:52 AM May 19,2016 05:35 AM WPF 3
loading
Tags: SfDataGrid
Craig Greenway
Asked On May 17, 2016 01:52 AM

Hi, I am struggling to get the SfDataGrid to automatically change to edit mode when you change cells.  Pressing F2 to start editing took me ages to figure out!

                <sf:SfDataGrid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="FieldsGrid" AutoGenerateColumns="False" ItemsSource="{Binding Path=Fields}" AllowEditing="True"
                               AllowSorting="False" AllowFiltering="False" EditTrigger="OnTap" CurrentCellActivating="FieldsGrid_OnCurrentCellActivating">
                    <syncfusion:SfDataGrid.Columns>
                        <syncfusion:GridTextColumn HeaderText="Field ID" MappingName="ID" AllowEditing="False" />
                        <syncfusion:GridTextColumn HeaderText="Field Name" MappingName="Name" />
                        <syncfusion:GridComboBoxColumn HeaderText="Data Type" MappingName="DataType" ItemsSource="{Binding Path=AvailableDataTypes}" />
                        <syncfusion:GridTextColumn HeaderText="Data Size" MappingName="DataSize" />
                    </syncfusion:SfDataGrid.Columns>
                </sf:SfDataGrid>

        private void FieldsGrid_OnCurrentCellActivating(object sender, CurrentCellActivatingEventArgs args)
        {           
            FieldsGrid.SelectionController.CurrentCellManager.BeginEdit();           
        }

The OnCurrentCellActivating event fires when I change cell, but the BeginEdit call is not putting the grid into edit mode.  I have to either click using the mouse or press F2 to edit.  What am I missing please?

Jai Ganesh S [Syncfusion]
Replied On May 18, 2016 05:23 AM

Hi Craig, 
 
You can go to edit mode when you click the cell by setting the EditTrigger as  OnTap like below, 
 
<Syncfusion:SfDataGrid x:Name="datagrid" 
                               AllowEditing="True" 
                               AllowFiltering="True" 
                               AllowSorting="True"  
                               EditTrigger="OnTap" 
                               AutoGenerateColumns="False" 
                               ItemsSource="{Binding ItemsCollection}" 
                               ShowGroupDropArea="True" 
                               ShowRowHeader="True"/> 
 
 
or if you want to edit the cell while key navigation  by call the BeginEdit() in CurrentcellActivated event like below, 
 
this.datagrid.CurrentCellActivated += datagrid_CurrentCellActivated; 
 
void datagrid_CurrentCellActivated(object sender, CurrentCellActivatedEventArgs args) 
 { 
    if(!datagrid.SelectionController.CurrentCellManager.CurrentCell.IsEditing && args.ActivationTrigger==ActivationTrigger.Keyboard) 
       datagrid.SelectionController.CurrentCellManager.BeginEdit();       
 } 
 
Regards, 
Jai Ganesh S 


Craig Greenway
Replied On May 18, 2016 06:06 AM

Thanks I chose the wrong event (activating rather than activated)

Jai Ganesh S [Syncfusion]
Replied On May 19, 2016 05:35 AM

Hi Craig, 
 
Thank you for the update. 
 
Please let us know if you need further assistance on this. 
 
Regards, 
Jai Ganesh S 


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.

;