DataGridView中的复选框 [英] Checkbox in DataGridView

查看:119
本文介绍了DataGridView中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在研究将警报应用于特定用户的项目。我使用VS 2008和vb.net作为语言。



我有两个网格。在一个网格中,我有用户的数据。例如手机号码,电子邮件和其他信息。在第二个网格中,我已经添加了一些警报。



我需要在警报gridview中的每一行附加两个复选框列。单击该复选框,将执行特定的数据库操作。



目前,我在数据网格视图中添加了复选框,但我无法检查/取消选中它们。



请帮我解决检查/取消检查问题并给我一个提示,以执行复选框点击的数据库操作。



这就是我在datagridview中添加复选框的方式



Hi,

I am working on project to apply the alarms to specific users. I am using VS 2008 and vb.net as a language.

I have two grids. In one grid, i have user's data. e.g Mobile no, email and other information. In second grid, i have some already added alarm.

I need to attach two checkbox colums in each row in alarm gridview. On click of that checkbox, particular database operation will execute.

Currently, i added checkboxes into the datagridview but i can't check/uncheck them.

Please help me to resolve the check/uncheck problem and give me a hint to perform database operations of checkbox click.

This is how i added checkbox into the datagridview

Dim email As DataGridViewCheckBoxColumn = New DataGridViewCheckBoxColumn(True)
Dim sms As DataGridViewCheckBoxColumn = New DataGridViewCheckBoxColumn(True)

email.HeaderText = "Email"
email.ReadOnly = False
sms.HeaderText = "SMS"
sms.ReadOnly = False

UserAlarmDataGridView.Columns.Add(email)

UserAlarmDataGridView.Columns.Add(sms)





我试图将列的readonly属性设置为false但它不起作用。



请帮助,我在截止日期.... ...... :(



I tried to make the column's readonly property to false but it doesn't work.

Please help, i m on deadline.......... :(

推荐答案

For Each rw As DataGridViewRow In DataGridView1.Rows
            If rw.Cells(6).Value = True Then REM Datagridview Checkbox checking
                REM Call another datagridview or Do something based on this value
                cmd = New SqlCommand("select * from tblEmp where empid =" & rw.Cells(0).Value & " ", con)
                da = New SqlDataAdapter(cmd)
                da.Fill(dt)
                If Not dt Is Nothing AndAlso dt.Rows.Count > 0 Then
                    DataGridView2.DataSource = dt
                End If
            End If
        Next


你写一个私人功能和运行时你选中/取消选中复选框我想,请给我清楚的详细信息
you write a private function and runtime you check/uncheck checkbox i think, please give me clear details


这篇关于DataGridView中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆