In DevExpress development, we often encounter the prompt "incorrect input string format" after xtraGrid binds data to cut or delete cell data!
Effect before solution:
After solution:
1. Create a RepositoryItemTextEdit and bind it to the column
[Csharp]
DevExpress. XtraEditors. Repository. RepositoryItemTextEdit dtAfter = new DevExpress. XtraEditors. Repository. RepositoryItemTextEdit ();
DtAfter. ParseEditValue + = new DevExpress. XtraEditors. Controls. ConvertEditValueEventHandler (dtText_ParseEditValue );
Gridview. Columns [stringInfo [0]. ToString ()]. ColumnEdit = dtAfter;
DtAfter. EditFormat. FormatType = DevExpress. Utils. FormatType. Numeric;
DtAfter. EditFormat. FormatString = "{0: N3 }";
DtAfter. DisplayFormat. FormatType = DevExpress. Utils. FormatType. Numeric;
DtAfter. DisplayFormat. FormatString = "{0: N3 }";
2. Implement the dtText_ParseEditValue event
[Csharp]
Void dtText_ParseEditValue (object sender, DevExpress. XtraEditors. Controls. ConvertEditValueEventArgs e)
{
TextEdit edit = sender as TextEdit;
Object obj = e. Value;
If (edit. Text = string. Empty)
{
If (edit. EditValue = null | edit. EditValue. ToString () = "")
{
E. Value = null;
}
}
Else
{
E. Value = obj;
}
}