我有一个显示4个字段(int,int,string,string)的ListView,当我插入错误的值时会崩溃并显示此错误" 输入字符串格式不正确"
我想处理这个错误,以便我的程序不会崩溃并显示我定义的错误,到目前为止,如果文本框为空,我有以下代码处理错误:
public void ListView1_ItemInserting(Object sender, ListViewInsertEventArgs e)
{
// Iterate through the values to verify if they are not empty.
foreach (DictionaryEntry de in e.Values)
{
if (de.Value == null)
{
Message.Text = "Cannot insert an empty value.";
e.Cancel = true;
}
}
}