Note that there are some explanatory texts on larger screens.

plurals
  1. POthe program do not access ValidatingEditor and InvalidValueException
    text
    copied!<p>I am using DevExpress DataGrid I'm filling it from excel.. If the user keep the field Name empty i need to give him an error message.. this my code:</p> <pre><code>using DevExpress.XtraGrid.Views.Base; using DevExpress.XtraGrid.Columns; using DevExpress.XtraEditors.Controls; using DevExpress.XtraGrid.Views.Grid; string FirstName = "First Name"; string FatherName = "Father Name"; string LastName = "Last Name"; private void simpleButton1_Click(object sender, System.EventArgs e) { try { OleDbConnection con = new OleDbConnection(); con.ConnectionString = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=C:\\Users\\pc\\Documents\\Emp.xlsx;Extended Properties=\"Excel 12.0;HDR=Yes\""; con.Open(); DataTable dtSchema; dtSchema = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" }); OleDbCommand Command = new OleDbCommand ("select * FROM [" + dtSchema.Rows[0]["TABLE_NAME"].ToString() + "]", con); OleDbDataAdapter da = new OleDbDataAdapter(Command); DataSet ds = new DataSet (); da.Fill(ds); dataGrid1.DataSource = ds.Tables[0]; } catch (Exception ex) { MessageBox.Show(ex.Message); } private void gridView3_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e) { GridView view = sender as GridView; if(view.FocusedColumn.FieldName == "FirstName") { string FirName = (e.Value.ToString()); if(FirName == null) { e.Valid = false; e.ErrorText = "Enter a First Name"; } } } private void gridView3_InvalidValueException(object sender, DevExpress.XtraEditors.Controls.InvalidValueExceptionEventArgs e) { //Do not perform any default action e.ExceptionMode = DevExpress.XtraEditors.Controls.ExceptionMode.NoAction; //Show the message with the error text specified MessageBox.Show(e.ErrorText); } </code></pre> <p>The problem is when I run the program.. the code do not access this code and it's not showing an error.. Could someone notice where's my fault ? Thank you so much</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload