FlexGrid for Silverlight

Keep edit mode of cell

  •  Gesh1k said 10 months ago:

    Is it possible to keep a cell in edit mode after pressing of Enter, Tab, or changing selection?

    I used :

    …
    CellEditEnding += (sender, args) =>
                                      {
                                          if(some conditions)
                                            args.Cancel = true;
                                      };
    …
    

    but it’s not working..

  •  Anupam_P16p said 9 months, 3 weeks ago:

    Hi,

    CellEditEnding won’t help here. Considering current cell lies in first row and first column, please try it this way instead:

    //Keep grid in edit mode if user hits Enter/Tab key while editor is active
                this.c1FlexGrid.PrepareCellForEdit += (sender, e) => {
                    if (e.Row == 0 && e.Column == 0)
                    {
                        var b = e.Editor as Border;
                        var tb = b.Child as TextBox;
                        if (tb != null)
                            tb.KeyDown += (s1, e1) =>
                            {
                                if (e1.Key == Key.Enter || e1.Key == Key.Tab)
                                    e1.Handled = true;
                            };
                    }
                };
    
                //Cancel selection
                this.c1FlexGrid.SelectionChanging += (sender, e) =>
                {
                    var flex = sender as C1.Silverlight.FlexGrid.C1FlexGrid;
                    if (e.CellRange.IsSingleCell)
                    {
                        if (flex.Selection.Row == 0 && flex.Selection.Column == 0)
                        {
                            e.Cancel = true;
                            flex.StartEditing(true);
                        }
                    }
                };
    

    Cheers,
    ~Anupam.

    Answer
  •  Gesh1k said 9 months, 3 weeks ago:

    Hi Anupam,

    It’s working.

    Thanks a lot!

  •  Anupam_P16p said 9 months, 3 weeks ago:

    You’re welcome :)

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.