Home Forums WinForms controls Xceed Grid for WinForms How to prevent a cell from leaving edit mode

Viewing 1 post (of 1 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17812 |

    To prevent the cell from leaving edit mode, you will need to handle ValidationError event of each DataCell in the grid and set the CancelEdit event argument to false.

    VB.NET

    gridControl1.BeginInit()

    gridControl1.DataSource = dataSet11
    gridControl1.DataMember = “Orders”

    Dim cell As DataCell

    For Each cell in gridControl1.DataRowTemplate.Cells
      AddHandler cell.ValidationError, AddressOf Me.cell_ValidationError
    Next cell

    gridControl1.EndInit()

    Private Sub cell_ValidationError( ByVal sender As Object, ByVal e As CellValidationErrorEventArgs )
      ‘ code to prevent the cell from exiting edit mode
      e.CancelEdit = False
    End Sub

    C#

    gridControl1.BeginInit();

    gridControl1.DataSource = dataSet11;
    gridControl1.DataMember = “Orders”;

    foreach( DataCell cell in gridControl1.DataRowTemplate.Cells )
    {
      cell.ValidationError += new CellValidationErrorEventHandler( this.cell_ValidationError );
    }

    gridControl1.EndInit();

    private void cell_ValidationError( object sender, CellValidationErrorEventArgs e )
    {
      // code to prevent the cell from exiting edit mode
      e.CancelEdit = false;
    }

    Imported from legacy forums. Posted by Xceed admin (had 804 views)

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.