加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

VB之旅-删除FlexGridLevel中选中的行及表中的记录

发布时间:2020-12-17 08:08:16 所属栏目:百科 来源:网络整理
导读:span style="font-family:SimHei;font-size:24px;"dim nowRow as integerPrivate Sub FlexGridLevel_MouseDown(Button As Integer,Shift As Integer,X As Single,Y As Single) With FlexGridLevel .Row = .MouseRow '设置激活单元格的行号为鼠标指针所在行 n
<span style="font-family:SimHei;font-size:24px;">dim nowRow as integer
Private Sub FlexGridLevel_MouseDown(Button As Integer,Shift As Integer,X As Single,Y As Single)
    With FlexGridLevel
        .Row = .MouseRow    '设置激活单元格的行号为鼠标指针所在行
        nowRow = .Row         '将单元格的行号附给nowRow 因为mousedown和mouseup是两个事件,所以要借助nowRow来传递选中行
        .Col = 0                       '设置单元格激活的列号为0
.Colsel=.Cols-1
    End With
End Sub
Private Sub FlexGridLevel_MouseUp(Button As Integer,Y As Single)
    With FlexGridLevel
        .RowSel = nowRow '使选中行其呈选中状态
        .ColSel = .Cols - 1    '使选中列其呈选中状态
    End With
End Sub
'删除FlexGridLevel中选中的行及表中的记录
Private Sub cmdDelete_Click()
    Dim mrc As ADODB.Recordset
    Dim txtSQL As String
    Dim MsgText As String
    If FlexGridLevel.RowSel = 0 Then '如果选中行为第一行
        MsgBox "请先选择要删除的用户",vbOKOnly + vbExclamation,"添加删除用户"
    Else
        txtSQL = "delete from user_info where userid='" & Trim(FlexGridLevel.TextMatrix(FlexGridLevel.Row,0)) & "'"
        Set mrc = ExecuteSQL(txtSQL,MsgText) '删除表中记录
        FlexGridLevel.RemoveItem FlexGridLevel.Row '删除选中行
        MsgBox "用户已成功删除",vbOKOnly + vbInformation,"添加删除用户"
    End If
End Sub</span>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读