回复 1楼Kissmint的帖子
你可以尝试下如下代码:
- void gcMultiRow1_CellValidating(object sender, CellValidatingEventArgs e)
- {
- if (e.FormattedValue is string && (e.FormattedValue as string).Length > 5)
- {
- MessageBox.Show("Text is too long!");
- if (gcMultiRow1.IsCurrentCellInEditMode)
- {
- if (gcMultiRow1.EditingControl is IEditingControl)
- {
- (gcMultiRow1.EditingControl as IEditingControl).PrepareEditingControlForEdit(true);
- }
- }
- else
- {
- gcMultiRow1.BeginEdit(true);
- }
- e.Cancel = true;
- }
- }
复制代码 |