If MessageBoxShow("确定要删除", MeText, MessageBoxButtonsYesNo, MessageBoxIconNone) = WindowsFormsDialogResultYes Then
Dim s As String = "delete from tablename where id=" & DataGridView1CurrentRowCells(0)Value
'执行删除 *** 作
End If
Else
MessageBoxShow("未选中任何信息")
End If
需要先编辑DataGridView的列,在里面的ColumnType里选择CheckBox即可答案修改:原来如此啊。以下是修改完毕的代码。
建command1,command2,command3,command4,check1,check2,check3
================
Sub Run()
If Check1Value = vbChecked Then
Open "c:\test\file1txt" For Output As 1
Print #1, InputBox("A")
Close
End If
If Check2Value = vbChecked Then
Open "c:\test\file2txt" For Output As 2
Print #2, InputBox("B")
Close
End If
If Check3Value = vbChecked Then
Open "c:\test\file3txt" For Output As 3
Print #3, InputBox("C")
Close
End If
End Sub
Private Sub Command1_Click()
Check1Value = vbChecked
Check2Value = vbChecked
Check3Value = vbUnchecked
End Sub
Private Sub Command2_Click()
Run
MsgBox "执行完毕"
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
Run
Command1_Click
MsgBox "已还原"
End Sub
Private Sub Form_Load()
Command1Caption = "默认"
Command2Caption = "确定"
Command3Caption = "取消"
Command4Caption = "还原"
Check1Caption = "A"
Check2Caption = "B"
Check3Caption = "C"
Check1Value = vbChecked
Check2Value = vbChecked
End Sub代码如下:
Private
Sub
Command1_Click()
If
Option1Value
=
True
Then
MsgBox
"你选择了复选框"
‘如果Option1被选中,则d出消息框
If
Check1Value
=
1
Then
MsgBox
"你选择了复选框"
‘如果Check1被选中,则d出消息框
else
if
Check1Value
=
0
Then
MsgBox
"你选择了复选框"
‘如果Check1被选中,则d出消息框
End
If
End
Sub
这个代码明白吗?CheckBox是复选框---需要同时选择几个条件时使用。
举例:
选修课程:语文,数学,英语,美术,音乐,。。。。
这时可以使用CheckBox,你可以同时选择几个不同的课程。
OptiongButton是单选按钮---需要在几个条件中
只
选定一个条件时使用。
举例:
性别:男,女,不选。
这时可以使用OptiongButton,当你选定一个时候,其他2个自动成为非选定状态。
如果你希望在不同类别里每类只许选择一项(单选)时,就需要使用
Frame
,把OptiongButton分组放置在“容器”里,这样一个容器里的OptiongButton就不会影响其他类别中的OptiongButton了。Private Sub Form_Load()
'属性栏内设置:List1Style = 1
'初始化
For i = 65 To 69
List1AddItem Chr(i)
Next i
MeShow
'设置a,c,e选中
For i = 0 To List1ListCount - 1
If LCase(List1List(i)) = "a" Then
List1Selected(i) = True
MsgBox List1List(i) & "选中了,谢谢"
End If
If LCase(List1List(i)) = "c" Then
List1Selected(i) = True
MsgBox List1List(i) & "选中了,谢谢"
End If
If LCase(List1List(i)) = "e" Then
List1Selected(i) = True
MsgBox List1List(i) & "选中了,谢谢"
End If
Next i
End Sub创建一个main过程用来处理标签1
Sub main()
Label1Caption = ""
If Check1Value = 1 Then Label1Caption = Label1Caption & Check1Caption
If Check2Value = 1 Then Label1Caption = Label1Caption & Check2Caption
If Check3Value = 1 Then Label1Caption = Label1Caption & Check3Caption
End Sub
Private Sub Check1_Click()
Call main '复选框调用main过程
End Sub
Private Sub Check2_Click()
Call main
End Sub
Private Sub Check3_Click()
Call main
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)