none
如何为类按钮编写事件? RRS feed

答案

  • 你好!

        我感觉是这样的,你可以多学习一些理论知识,你对事件订阅的原理可能不是很清楚!如果只是照着其他代码来模仿,很容易发生你上面遇到的问题,因为你不清楚例子里那么写的原因,所以就出现问题了!


    周雪峰
    2010年7月1日 8:53
    版主

全部回复

  • 难道是过于简单了,没人回答?
    2010年6月23日 6:57
  • 你好!
         订阅这个按钮的Click事件,然后事件处理函数中写代码就可以了!
    周雪峰
    2010年6月24日 14:24
    版主
  • 谢谢周版主!

        能具体写一下吗?

        我以BindingNavigator为基础,做了一个新类,扩展了一下它的功能,加了几个按钮:筛选、打印、查询等,点击筛选后,打开筛选对话框。

        在窗体中,为按钮加Click事件很简单:

          Private Sub BindingNavigatorFilterItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorFilterItem.Click
                  FilterDialog.ShowDialog()
          End Sub

        但,我想把它加到类中,这样,维护就简单了。可怎么写呢?

        不好意思,麻烦你了,入门真是个痛苦的过程。

    2010年6月24日 23:22
  • 你好!

         在类中添加也是类似的!


    周雪峰
    2010年6月25日 4:05
    版主
  • 但我把这段代码复制过去,根本不好用。
    2010年6月25日 5:53
  • 你好!

         请问遇到什么问题?编译出错,还是怎样?


    周雪峰
    2010年6月25日 6:18
    版主
  • 没反应。

    根本未执行。
    2010年6月25日 7:46
  • 难道这是个难题?

    2010年6月28日 0:53
  • 你好!

         这个问题十分的简单,我实在猜测不出你具体是怎样做的,请提供相关的类代码,你怎么复制的?


    周雪峰
    2010年6月28日 4:59
    版主
  • 你好,周版主!

        这是我以BindingNavigator为基础,做了一个新类,扩展了一下它的功能,加了几个按钮:筛选、打印、查询等,相关功能未完全加上。

        最后黑体部分代码:点击查询后,打开查询对话框。若在窗体中,在查询按钮上直接为Click事件加上这段代码,则可打开查询对话框,但用在类中,则不行。

        另外,这个组件,在VS2010中,用设计器打开时,总报错:

            警告 1 对象与目标类型不匹配。 E:\Erp\Erp\Erp\HBindingNavigator.Designer.vb 124 0 
            警告 2 类型“System.Windows.Forms.ToolStripTextBox”没有名为“ToolTipText”的属性。 E:\Erp\Erp\Erp\HBindingNavigator.Designer.vb 125 0 

        请指教!

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class HBindingNavigator
        Inherits System.Windows.Forms.BindingNavigator

        'Form 重写 Dispose,以清理组件列表。
        <System.Diagnostics.DebuggerNonUserCode()> _
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
            MyBase.Dispose(disposing)
        End Sub

        'Windows 窗体设计器所必需的
        Private components As System.ComponentModel.IContainer

        '注意: 以下过程是 Windows 窗体设计器所必需的
        '可以使用 Windows 窗体设计器修改它。
        '不要使用代码编辑器修改它。
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            Me.components = New System.ComponentModel.Container()
            Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(HBindingNavigator))
            Me.BindingNavigator = New System.Windows.Forms.BindingNavigator(Me.components)
            Me.BindingNavigatorAddNewItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorCountItem = New System.Windows.Forms.ToolStripLabel()
            Me.BindingNavigatorDeleteItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorMoveFirstItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorMovePreviousItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorSeparator = New System.Windows.Forms.ToolStripSeparator()
            Me.BindingNavigatorPositionItem = New System.Windows.Forms.ToolStripTextBox()
            Me.BindingNavigatorSeparator1 = New System.Windows.Forms.ToolStripSeparator()
            Me.BindingNavigatorMoveNextItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorMoveLastItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorSeparator2 = New System.Windows.Forms.ToolStripSeparator()
            Me.BindingNavigatorEditItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorReplaceItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorImportItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorConfirmItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorSeparator3 = New System.Windows.Forms.ToolStripSeparator()
            Me.BindingNavigatorFilterItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorPreviewItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorPrintItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorQueryItem = New System.Windows.Forms.ToolStripButton()
            Me.BindingNavigatorSeparator4 = New System.Windows.Forms.ToolStripSeparator()
            Me.BindingNavigatorEnterItem = New System.Windows.Forms.ToolStripButton()
            CType(Me.BindingNavigator, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.BindingNavigator.SuspendLayout()
            CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.SuspendLayout()
            '
            'BindingNavigator
            '
            Me.BindingNavigator.AddNewItem = Me.BindingNavigatorAddNewItem
            Me.BindingNavigator.CountItem = Me.BindingNavigatorCountItem
            Me.BindingNavigator.DeleteItem = Me.BindingNavigatorDeleteItem
            Me.BindingNavigator.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BindingNavigatorMoveFirstItem, Me.BindingNavigatorMovePreviousItem, Me.BindingNavigatorSeparator, Me.BindingNavigatorPositionItem, Me.BindingNavigatorCountItem, Me.BindingNavigatorSeparator1, Me.BindingNavigatorMoveNextItem, Me.BindingNavigatorMoveLastItem, Me.BindingNavigatorSeparator2, Me.BindingNavigatorAddNewItem, Me.BindingNavigatorEditItem, Me.BindingNavigatorDeleteItem, Me.BindingNavigatorReplaceItem, Me.BindingNavigatorImportItem, Me.BindingNavigatorConfirmItem, Me.BindingNavigatorSeparator3, Me.BindingNavigatorFilterItem, Me.BindingNavigatorPreviewItem, Me.BindingNavigatorPrintItem, Me.BindingNavigatorQueryItem, Me.BindingNavigatorSeparator4, Me.BindingNavigatorEnterItem})
            Me.BindingNavigator.Location = New System.Drawing.Point(0, 0)
            Me.BindingNavigator.MoveFirstItem = Me.BindingNavigatorMoveFirstItem
            Me.BindingNavigator.MoveLastItem = Me.BindingNavigatorMoveLastItem
            Me.BindingNavigator.MoveNextItem = Me.BindingNavigatorMoveNextItem
            Me.BindingNavigator.MovePreviousItem = Me.BindingNavigatorMovePreviousItem
            Me.BindingNavigator.Name = "BindingNavigator"
            Me.BindingNavigator.PositionItem = Me.BindingNavigatorPositionItem
            Me.BindingNavigator.Size = New System.Drawing.Size(100, 25)
            Me.BindingNavigator.TabIndex = 0
            Me.BindingNavigator.Text = "BindingNavigator"
            '
            'BindingNavigatorAddNewItem
            '
            Me.BindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorAddNewItem.Image = CType(resources.GetObject("BindingNavigatorAddNewItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorAddNewItem.Name = "BindingNavigatorAddNewItem"
            Me.BindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorAddNewItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorAddNewItem.Text = "添加(&A)"
            '
            'BindingNavigatorCountItem
            '
            Me.BindingNavigatorCountItem.Name = "BindingNavigatorCountItem"
            Me.BindingNavigatorCountItem.Size = New System.Drawing.Size(35, 12)
            Me.BindingNavigatorCountItem.Text = "/ {0}"
            Me.BindingNavigatorCountItem.ToolTipText = "总项数"
            '
            'BindingNavigatorDeleteItem
            '
            Me.BindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorDeleteItem.Image = CType(resources.GetObject("BindingNavigatorDeleteItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorDeleteItem.Name = "BindingNavigatorDeleteItem"
            Me.BindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorDeleteItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorDeleteItem.Text = "删除(&D)"
            '
            'BindingNavigatorMoveFirstItem
            '
            Me.BindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorMoveFirstItem.Image = CType(resources.GetObject("BindingNavigatorMoveFirstItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorMoveFirstItem.Name = "BindingNavigatorMoveFirstItem"
            Me.BindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorMoveFirstItem.Size = New System.Drawing.Size(23, 22)
            Me.BindingNavigatorMoveFirstItem.Text = "第一条"
            '
            'BindingNavigatorMovePreviousItem
            '
            Me.BindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorMovePreviousItem.Image = CType(resources.GetObject("BindingNavigatorMovePreviousItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorMovePreviousItem.Name = "BindingNavigatorMovePreviousItem"
            Me.BindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorMovePreviousItem.Size = New System.Drawing.Size(23, 22)
            Me.BindingNavigatorMovePreviousItem.Text = "上一条"
            '
            'BindingNavigatorSeparator
            '
            Me.BindingNavigatorSeparator.Name = "BindingNavigatorSeparator"
            Me.BindingNavigatorSeparator.Size = New System.Drawing.Size(6, 25)
            '
            'BindingNavigatorPositionItem
            '
            Me.BindingNavigatorPositionItem.AccessibleName = "位置"
            Me.BindingNavigatorPositionItem.AutoSize = False
            Me.BindingNavigatorPositionItem.Name = "BindingNavigatorPositionItem"
            Me.BindingNavigatorPositionItem.Size = New System.Drawing.Size(50, 21)
            Me.BindingNavigatorPositionItem.Text = "0"
            Me.BindingNavigatorPositionItem.ToolTipText = "当前位置"
            '
            'BindingNavigatorSeparator1
            '
            Me.BindingNavigatorSeparator1.Name = "BindingNavigatorSeparator1"
            Me.BindingNavigatorSeparator1.Size = New System.Drawing.Size(6, 6)
            '
            'BindingNavigatorMoveNextItem
            '
            Me.BindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorMoveNextItem.Image = CType(resources.GetObject("BindingNavigatorMoveNextItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorMoveNextItem.Name = "BindingNavigatorMoveNextItem"
            Me.BindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorMoveNextItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorMoveNextItem.Text = "下一条"
            '
            'BindingNavigatorMoveLastItem
            '
            Me.BindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorMoveLastItem.Image = CType(resources.GetObject("BindingNavigatorMoveLastItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorMoveLastItem.Name = "BindingNavigatorMoveLastItem"
            Me.BindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorMoveLastItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorMoveLastItem.Text = "最后一条"
            '
            'BindingNavigatorSeparator2
            '
            Me.BindingNavigatorSeparator2.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
            Me.BindingNavigatorSeparator2.Name = "BindingNavigatorSeparator2"
            Me.BindingNavigatorSeparator2.Size = New System.Drawing.Size(6, 6)
            '
            'BindingNavigatorEditItem
            '
            Me.BindingNavigatorEditItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorEditItem.Image = CType(resources.GetObject("BindingNavigatorEditItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorEditItem.Name = "BindingNavigatorEditItem"
            Me.BindingNavigatorEditItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorEditItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorEditItem.Text = "编辑(&E)"
            '
            'BindingNavigatorReplaceItem
            '
            Me.BindingNavigatorReplaceItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorReplaceItem.Image = CType(resources.GetObject("BindingNavigatorReplaceItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorReplaceItem.Name = "BindingNavigatorReplaceItem"
            Me.BindingNavigatorReplaceItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorReplaceItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorReplaceItem.Text = "查找和替换(&R)"
            '
            'BindingNavigatorImportItem
            '
            Me.BindingNavigatorImportItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorImportItem.Image = CType(resources.GetObject("BindingNavigatorImportItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorImportItem.Name = "BindingNavigatorImportItem"
            Me.BindingNavigatorImportItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorImportItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorImportItem.Text = "导入(&I)"
            '
            'BindingNavigatorConfirmItem
            '
            Me.BindingNavigatorConfirmItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorConfirmItem.Image = CType(resources.GetObject("BindingNavigatorConfirmItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorConfirmItem.Name = "BindingNavigatorConfirmItem"
            Me.BindingNavigatorConfirmItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorConfirmItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorConfirmItem.Text = "复核(&O)"
            '
            'BindingNavigatorSeparator3
            '
            Me.BindingNavigatorSeparator3.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
            Me.BindingNavigatorSeparator3.Name = "BindingNavigatorSeparator3"
            Me.BindingNavigatorSeparator3.Size = New System.Drawing.Size(6, 6)
            '
            'BindingNavigatorFilterItem
            '
            Me.BindingNavigatorFilterItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorFilterItem.Image = CType(resources.GetObject("BindingNavigatorFilterItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorFilterItem.Name = "BindingNavigatorFilterItem"
            Me.BindingNavigatorFilterItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorFilterItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorFilterItem.Text = "搜索(&F)"
            '
            'BindingNavigatorPreviewItem
            '
            Me.BindingNavigatorPreviewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorPreviewItem.Image = CType(resources.GetObject("BindingNavigatorPreviewItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorPreviewItem.Name = "BindingNavigatorPreviewItem"
            Me.BindingNavigatorPreviewItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorPreviewItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorPreviewItem.Text = "预览(&V)"
            '
            'BindingNavigatorPrintItem
            '
            Me.BindingNavigatorPrintItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorPrintItem.Image = CType(resources.GetObject("BindingNavigatorPrintItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorPrintItem.Name = "BindingNavigatorPrintItem"
            Me.BindingNavigatorPrintItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorPrintItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorPrintItem.Text = "打印(&P)"
            '
            'BindingNavigatorQueryItem
            '
            Me.BindingNavigatorQueryItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorQueryItem.Image = CType(resources.GetObject("BindingNavigatorQueryItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorQueryItem.Name = "BindingNavigatorQueryItem"
            Me.BindingNavigatorQueryItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorQueryItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorQueryItem.Text = "查询(&Q)"
            '
            'BindingNavigatorSeparator4
            '
            Me.BindingNavigatorSeparator4.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
            Me.BindingNavigatorSeparator4.Name = "BindingNavigatorSeparator4"
            Me.BindingNavigatorSeparator4.Size = New System.Drawing.Size(6, 6)
            '
            'BindingNavigatorEnterItem
            '
            Me.BindingNavigatorEnterItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.BindingNavigatorEnterItem.Image = CType(resources.GetObject("BindingNavigatorEnterItem.Image"), System.Drawing.Image)
            Me.BindingNavigatorEnterItem.Name = "BindingNavigatorEnterItem"
            Me.BindingNavigatorEnterItem.RightToLeftAutoMirrorImage = True
            Me.BindingNavigatorEnterItem.Size = New System.Drawing.Size(23, 20)
            Me.BindingNavigatorEnterItem.Text = "横向编辑(&T)"
            CType(Me.BindingNavigator, System.ComponentModel.ISupportInitialize).EndInit()
            Me.BindingNavigator.ResumeLayout(False)
            Me.BindingNavigator.PerformLayout()
            CType(Me, System.ComponentModel.ISupportInitialize).EndInit()
            Me.ResumeLayout(False)

        End Sub
        Friend WithEvents BindingNavigator As System.Windows.Forms.BindingNavigator
        Friend WithEvents BindingNavigatorAddNewItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorCountItem As System.Windows.Forms.ToolStripLabel
        Friend WithEvents BindingNavigatorDeleteItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorMoveFirstItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorMovePreviousItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorSeparator As System.Windows.Forms.ToolStripSeparator
        Friend WithEvents BindingNavigatorPositionItem As System.Windows.Forms.ToolStripTextBox
        Friend WithEvents BindingNavigatorSeparator1 As System.Windows.Forms.ToolStripSeparator
        Friend WithEvents BindingNavigatorMoveNextItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorMoveLastItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorSeparator2 As System.Windows.Forms.ToolStripSeparator
        Friend WithEvents BindingNavigatorEditItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorImportItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorSeparator3 As System.Windows.Forms.ToolStripSeparator
        Friend WithEvents BindingNavigatorPrintItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorQueryItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorConfirmItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorReplaceItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorFilterItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorSeparator4 As System.Windows.Forms.ToolStripSeparator
        Friend WithEvents BindingNavigatorEnterItem As System.Windows.Forms.ToolStripButton
        Friend WithEvents BindingNavigatorPreviewItem As System.Windows.Forms.ToolStripButton
        Public Overrides Sub AddStandardItems()
            MyBase.AddStandardItems()
            Me.Items.Add(Me.BindingNavigatorEditItem)
            Me.Items.Add(Me.BindingNavigatorReplaceItem)
            Me.Items.Add(Me.BindingNavigatorImportItem)
            Me.Items.Add(Me.BindingNavigatorConfirmItem)
            Me.Items.Add(Me.BindingNavigatorSeparator3)
            Me.Items.Add(Me.BindingNavigatorFilterItem)
            Me.Items.Add(Me.BindingNavigatorPreviewItem)
            Me.Items.Add(Me.BindingNavigatorPrintItem)
            Me.Items.Add(Me.BindingNavigatorQueryItem)
            Me.Items.Add(Me.BindingNavigatorSeparator4)
            Me.Items.Add(Me.BindingNavigatorEnterItem)
        End Sub
        Protected Overrides Sub RefreshItemsCore()
            MyBase.RefreshItemsCore()
            If Me.BindingSource Is Nothing Then
                Me.Enabled = False
            Else
                Me.Enabled = True
            End If
        End Sub
        Private EditModeValue As Boolean
        Public Property EditMode() As Boolean
            Get
                Return EditModeValue
            End Get
            Set(ByVal value As Boolean)
                EditModeValue = value
            End Set
        End Property


        Private Sub BindingNavigatorQueryItemClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorQueryItem.Click
            QueryDialog.ShowDialog()
        End Sub
    End Class

     

    2010年6月28日 23:42
  • 你好!

         你把订阅事件的代码放到构造函数里!

         我不知道你是如何操作的,你是定义类,那窗体设计器生成的代码是怎么来的呢!


    周雪峰
    2010年6月29日 5:44
    版主
  • 你好,周版主!

        能否举例具体说明一下,如何在BindingNavigator上加一个按钮,并填写Click事件代码?

    2010年6月30日 23:47
  • 你好!

        我感觉是这样的,你可以多学习一些理论知识,你对事件订阅的原理可能不是很清楚!如果只是照着其他代码来模仿,很容易发生你上面遇到的问题,因为你不清楚例子里那么写的原因,所以就出现问题了!


    周雪峰
    2010年7月1日 8:53
    版主