关于checkbox的问题,急~~

nices0028 2006-07-01 08:18:50
我这边做了个选课表
学号 计算机 数学 英语
002541 1 1 0
002542 0 0 1 (1代表选,0代表不选)

我在WINFORM中做了三个 checkbox,分别代表计算机、数学、英语
另外在WINFORM上还有个datagrid 用来显示 上面选课表记录
我想得到的效果是:
当选中DATAGRID中的一行数据,如果查询选课表,如果查询结果是 1,
在相应的CHECKBOX的复选框就自动打勾。
即,当我选中 002541 1 1 0
checkbox1和checkbox2要打勾~
小弟先谢了~~~
...全文
107 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
nices0028 2006-07-01
  • 打赏
  • 举报
回复
Dim command1 As New SqlCommand("select 计算机 from 选课表 where 学号='" + Me.DataGrid1.Item(DataGrid1.CurrentRowIndex, 0) + "'")
command1.CommandType = CommandType.Text
command1.Connection = conn
If command1.ExecuteScalar = 1 Then
CheckBox1.Checked = True
Else
CheckBox1.Checked = False
End If

Dim command2 As New SqlCommand("select 数学 from 选课表 where 学号='" + Me.DataGrid1.Item(DataGrid1.CurrentRowIndex, 0) + "'")
command2.CommandType = CommandType.Text
command2.Connection = conn
If command2.ExecuteScalar = 1 Then
CheckBox2.Checked = True
Else
CheckBox2.Checked = False
End If

Dim command3 As New SqlCommand("select 英语 from 选课表 where 学号='" + Me.DataGrid1.Item(DataGrid1.CurrentRowIndex, 0) + "'")
command3.CommandType = CommandType.Text
command3.Connection = conn
If command2.ExecuteScalar = 1 Then
CheckBox3.Checked = True
Else
CheckBox3.Checked = False
End If


小弟自己做出来了~~~~
兔子-顾问 2006-07-01
  • 打赏
  • 举报
回复
都可以用语言表达出来。为什么不能写出代码呢?

16,552

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧