Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的表单中有一个 datagridview 如何在离开当前行时验证单元格。
在每个更改的选定索引上保存当前索引,但在保存之前,只需从上一个选定行获取数据并验证它...
这是 Windows 窗体的答案(问题被标记为 ASP.NET,但据我所知,网络上没有 DataGridView 之类的东西):
处理RowValidating事件并验证那里的行。如果该行的值无效,则在ErrorText该行的属性中设置错误消息,并设置e.Cancel = True.
RowValidating
ErrorText
e.Cancel = True
最后在RowValidated事件中,将行的ErrorText属性设置为空字符串。
RowValidated