datagridview combox和复选框 [英] datagridview combox and checkbox

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

问题描述

大家早上好
有datagridview,因为我在上面有datagridviewcombobox列,我分配了两个值,但是默认情况下加载时,我无法将第一个值显示为默认值,我该怎么做呢?
第二,当我从数据库中检索值为0或1时,该datagridview中具有复选框列.当检索到的值为1时,将自动选中该行的复选框;当检索到的值为0时,则自动取消选中该行的复选框我可以做这个?请帮我...

感谢和问候,
Firoz.

good morning to all
have datagridview in that i have datagridviewcombobox column on that i assigned two values but when load by default i am not able to show the first value as default value how i can do this?
and second i have checkbox column in that datagridview when i am retrieving value from database as 0 or 1. when there retrieved value is 1 then checkbox of that row is automatic checked and when retrieved value is 0 then checkbox ot that row is automatically unchecked how i can do this? please help me...

thanks and regards,
Firoz.

推荐答案


对于第一个问题,您必须在网格填充时执行此操作,
dgvAttendance.Rows [i] .Cells [0] .Value ="value";

对于第二个问题,您必须这样做

foreach(dgvSharesell.Rows中的DataGridViewRow dr)
{
如果(dr.Cells [0] .Value!= null)
{
如果(bool.Parse(dr.Cells [0] .Value.ToString())== true)
{
}
}
}
Hi ,
For the first question u have to do this at the time of grid fill,
dgvAttendance.Rows[i].Cells[0].Value = "value";

for the second question u have to do this

foreach (DataGridViewRow dr in dgvSharesell.Rows)
{
if (dr.Cells[0].Value != null)
{
if (bool.Parse(dr.Cells[0].Value.ToString()) == true)
{
}
}
}


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

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