| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 992 人关注过本帖
标题:用右键单击行头换行之前能不能先发生`_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
快速回复:用右键单击行头换行之前能不能先发生`_RowValidating事件。 帮忙
数据加载中...
 
   



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

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