“取消"在DataGridView CellValidating事件中给出了构建错误 [英] "e.cancel" gives Build Error in DataGridView CellValidating Event

查看:176
本文介绍了“取消"在DataGridView CellValidating事件中给出了构建错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

构建项目时,我的e.cancel语句出现以下错误:

``取消''不是``System.Windows.Forms.DataGridViewCellEventArgs''的成员

这是我的活动代码:

When I Build my project, I get the following error on my e.cancel statement:

''cancel'' is not a member of ''System.Windows.Forms.DataGridViewCellEventArgs''

Here''s the code in my event:

Private Sub dgvPhysCME_CellValidating(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles dgvPhysCME.CellValueChanged

    'Bypass CellValidation when building/showing DataGridView
    If e.RowIndex = -1 Then Exit Sub

    'Clear ErrorText before testing cell value
    dgvPhysCME.Rows(e.RowIndex).ErrorText = ""

    'If cell is not null, exit sub
    If Not IsDBNull(dgvPhysCME.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) Then Exit Sub

    dgvPhysCME.Rows(e.RowIndex).ErrorText = "Field must not be empty"

    '*** This is where I'm getting the Build Error ***
    e.cancel = True

End Sub

推荐答案

您处理了错误的事件.
必须是:
You handle the wrong event.
It must be :
private void dgvPhysCME_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) Handles dgvPhysCME.CellValidating




DataGridViewCellValidatingEventArgs具有取消属性.

欢呼




The DataGridViewCellValidatingEventArgs has a Cancel property.

Cheers


请尝试e.Cancel:C#和VB区分大小写.
此外,您使用了错误的eventargs:应该具有DataGridViewCellValidatingEventArgs.请参阅 MSDN [
Try e.Cancel instead: C# and VB are case sensitive.
Additionally, you are using the wrong eventargs: DataGridViewCellValidatingEventArgs is what you should have. See MSDN[^] for details.


这篇关于“取消"在DataGridView CellValidating事件中给出了构建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆