窗体功能:添加,删除用户。
步骤:
1,添加用户
添加用户没有什么困难,主要是判断不让填入重复的用户名;添加完毕后显示列表要进行更新。
2,删除用户
删除用户首先要选中要删除的字段,在这里我用到了如下代码来完成只选择一行数据:
'用鼠标选中MyFlexGrid中的项,使其只能选中一行
Private Sub MyFlexGrid_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
With MyFlexGrid
.Row = .MouseRow
CurrentRow = .Row
.Col = 0
End With
End Sub
'选中一条记录
Private Sub MyFlexGrid_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
With MyFlexGrid
If CurrentRow > 0 Then
.RowSel = CurrentRow
.ColSel = .Cols - 1
End If
End With
End Sub
当CurrentRow大于0时才可以进行删除(当等于0时选择的是标题)。