SyncFusion GridDataBoundGrid数据绑定问题

时间:2011-01-06 22:33:44

标签: c# winforms syncfusion

我正在使用Syncfusion的GridDataBoundGrid控件并绑定我的自定义List。 其中一个属性是Nullable DateTime(DateTime?)。当我向网格添加一个新行并在DateTime列中开始编辑时,如果我键入字母数字,则会显示一个消息框,例如“XX不是Nullable'1的有效值”。 1.我如何处理这个问题以增加一些更有意义的消息?

我很感激解决方案。

2 个答案:

答案 0 :(得分:4)

完成单元格编辑后,使用DirectSaveCellInfo属性进行保存。

this.gridDataBoundGrid1.Binder.DirectSaveCellInfo = true;

答案 1 :(得分:1)

在显示错误消息之前将触发CurrentCellErrorMessage事件。您可以处理此事件并显示自定义MessageBox并取消该事件。您还可以将自定义文本设置为Text属性。以下代码显示了相同的实现。

private void Form1_Load(object sender, EventArgs e)
{
this.gridDataBoundGrid.CurrentCellErrorMessage += new GridCurrentCellErrorMessageEventHandler(gridDataBoundGrid_CurrentCellErrorMessage);
}

void gridDataBoundGrid_CurrentCellErrorMessage(object sender, GridCurrentCellErrorMessageEventArgs e)
{
//e.Text = "My Text";
MessageBox.Show("Type your custom message here. The original text is: \"" + e.Text+ "\"");
e.Cancel = true;
}
相关问题