如果在c#的datagridview中选中了复选框,则只选择组合框 [英] only select combobox if checkbox is selected in datagridview in c#

查看:89
本文介绍了如果在c#的datagridview中选中了复选框,则只选择组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows窗体应用。我在网格视图上显示我的数据,每行有两个额外的列名,复选框和组合框列。我想要当我勾选复选框时,它不能让我从组合框中选择任何只有特定行的东西。但对于未选中的其余行复选框,我必须能够从组合框中选择值。

i am working on windows form app. i m displaying my data on grid view with two extra column name, checkbox and combobox column on each row. i want when i tick checkbox it must not let me choose any thing from combobox for only that particular Row. but for rest of the rows with unselected check box i must be able to select value from combobox.

推荐答案

对代码进行一些更改

Make a little change in your code
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;



并且在GridView1_CellStateChanged事件中没有直接应用此


and in the GridView1_CellStateChanged event without directly applying this

SplitMethod.ReadOnly = true;// it will always make the whole column readonly



尝试使用这个


try using this

dataGridView1.CurrentRow.Cells[i].ReadOnly = true;//i is the column index of the combobox column



如需进一步查询,请随时询问。


For further query feel free to ask.


这篇关于如果在c#的datagridview中选中了复选框,则只选择组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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