One tap add text in cell

I need, when I click once on the cell the cell value changed to "/", when I double-click the cell value changed to "X", I do not understand how to assign the value of a particular cell.


3 Replies

JA Jayaraman Ayyanar Syncfusion Team March 26, 2018 09:41 AM UTC

Hi Georgy, 
 
Thanks for contacting Syncfusion support. 
 
We have checked your query. The query for the “One tap add text in cell” is which you can achieve by using the GridTappedEvent and GridDoubleTapped event where you can change the value of the particular cell which satisfies your requirement. In case , if you want to change the particular cell value when tapping the particular cell which you can also achieve by using the GridTappedEvent and GridDoubleTapped events with the condition for the specific RowCoumnIndex to change the Cell Value. 
 
Refer the below code snippets  
public MainPage() 
        { 
            InitializeComponent(); 
            dataGrid.GridTapped += DataGrid_GridTapped; 
            dataGrid.GridDoubleTapped += DataGrid_GridDoubleTapped; 
        } 
 
        private void DataGrid_GridDoubleTapped(object sender, GridDoubleTappedEventArgs e) 
        { 
            //Changing the CellValue when double tapping the particular cell 
            if (e.RowColumnIndex.RowIndex==2 && e.RowColumnIndex.ColumnIndex==3) 
            viewModel.OrdersInfo[1].LastName = "X"; 
 
            //Changing the CellValue when double tapping the grid. 
          //  viewModel.OrdersInfo[5].LastName = "X"; 
        } 
 
        private void DataGrid_GridTapped(object sender, GridTappedEventArgs e) 
        { 
            //Changing the CellValue when tapping the particular cell 
            if (e.RowColumnIndex.RowIndex == 2 && e.RowColumnIndex.ColumnIndex == 3) 
                viewModel.OrdersInfo[1].LastName = "/"; 
 
            //Changing the CellValue when single tapping the grid. 
          //  viewModel.OrdersInfo[5].LastName = "/"; 
        } 
 
We  have prepared a sample for your requirement and you can download the same from the below link. 
 
Regards, 
Jayaraman. 



GB Georgy Bekurin March 26, 2018 01:20 PM UTC

Thank you very much, but how i can add "x" or "/" not delete another "x" or "/", if cell have "x", i added to cell another "x" and that cell equals "xx"?


JA Jayaraman Ayyanar Syncfusion Team March 27, 2018 07:00 AM UTC

Hi Georgy,  
 
We have checked your query. Your requirement for the grid cell value to change to XX when the cell value is X can be achieved by using the following logics in  GridTappedEvent and GridDoubleTapped event. 
 
Refer the below code logics 
 string value = null;  
 private void DataGrid_GridDoubleTapped(object sender, GridDoubleTappedEventArgs e) 
        { 
            //Changing the CellValue when double tapping the particular cell 
            if (e.RowColumnIndex.RowIndex==2 && e.RowColumnIndex.ColumnIndex==3) 
            { 
                if (viewModel.OrdersInfo[1].LastName == "X" || value == "X") 
                { 
                    viewModel.OrdersInfo[1].LastName = "XX"; 
                } 
                else 
                    viewModel.OrdersInfo[1].LastName = "X"; 
            } 
 
              value = viewModel.OrdersInfo[1].LastName; 
 
            //Changing the CellValue when double tapping the grid. 
            //  viewModel.OrdersInfo[5].LastName = "X"; 
        } 
 
We have prepared a sample for your requirement and you can download the same from the link below. 
 
Regards, 
Jayaraman. 


Loader.
Up arrow icon