标题:用右键单击行头换行之前能不能先发生`_RowValidating事件。 帮忙
取消只看楼主
shsoo99
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-8-29
 问题点数:0 回复次数:0 
用右键单击行头换行之前能不能先发生`_RowValidating事件。 帮忙
用右键单击行头换行之前能不能先发生`_RowValidating事件
Private Sub DataGridView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseDown
        Dim hti As Windows.Forms.DataGridView.HitTestInfo
        hti = Me.DataGridView1.HitTest(e.X, e.Y)
        '選択行の索引
        Dim selectindex As Integer = hti.RowIndex
        '選択行
        Dim dgr As DataGridViewRow = DataGridView1.Rows(selectindex)
        If e.Button = Windows.Forms.MouseButtons.Right And hti.Type = DataGridViewHitTestType.RowHeader Then
            dgr.HeaderCell.ContextMenuStrip = ContextMenuStrip1
            'DataGridView1.ContextMenuStrip = Me.ContextMenuStrip1
            Me.DataGridView1.Focus()
        Else
            DataGridView1.ContextMenuStrip = Nothing
            Exit Sub
        End If

      

        If selectindex >= 0 And DataGridView1.SelectedRows.Count >= 0 Then

            Me.DataGridView1.ClearSelection()


            DataGridView1.Rows(selectindex).DefaultCellStyle.SelectionBackColor = Nothing
            DataGridView1.Rows(selectindex).DefaultCellStyle.SelectionForeColor = Nothing

            dgr.Selected = True

★★  在这里能不能先触发`_RowValidating事件,然后再选中行???????????
            dgr.DataGridView.CurrentCell = dgr.DataGridView.Rows(selectindex).Cells(1)

        ElseIf selectindex >= 0 And DataGridView1.SelectedRows.Contains(dgr) Then

        DataGridView1.ClearSelection()

        dgr.Selected = True

        dgr.DataGridView.CurrentCell = dgr.DataGridView.Rows(selectindex).Cells(1)
        End If
    End Sub
搜索更多相关主题的帖子: 单击 行头 
2008-09-04 16:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-231418-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.047953 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved