如果勾选了复选框,如何更改选定的行comboBox [英] how to make changes to selected row comboBox if its checkbox is ticked
问题描述
我有一个gridview,在gridView中我有复选框和组合框。
i只有在未勾选复选框时才需要从组合框中选择特定项目,如果勾选则不能选择它。
i使用以下代码:
I have a gridview and in gridView i have checkbox and combobox.
i need to select particular item from combobox only if the check box is not ticked, if it is ticked it must not select it.
i used following code:
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
object obj = GridView1.Rows[i].Cells[0];
if (((obj != null)))
{
DataGridViewCheckBoxCell checkBox1 = (DataGridViewCheckBoxCell)obj;
object objValue = checkBox1.Value;
if (((objValue != null)))
{
bool @checked = (bool)objValue;
if ((@checked))
{
SplitMethod.ReadOnly = true;
}
else
{
SplitMethod.ReadOnly = false;
}
}
}
}
如果我选择第一行复选框就知道问题,这样我就可以选择其余的组合框了。 />
简单地说:
网格视图中的每一行都有复选框和组合框,所以当我选中每一行复选框时它必须阻止我仅更改组合框而不是其余的行。
如果没有选中复选框,
i必须能够对其他行组合框进行更改。
know the problem if i select first row checkbox so it enable me to select rest of combobox as well.
simply:
each row in grid view has check box and combo box, so when i select each row check box so it must stop me to make changes to only that combobox not rest of the rows.
i must me able to make changes to other rows combobox if it check box is not selected.
推荐答案
你好,
你可能需要使用itemcommand事件。并检查以下链接。它可以帮到你。
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.itemcommand.aspx [ ^ ]
问候,
Prakash.T
probably you need to use itemcommand event. and check the following link. it will may help you.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.itemcommand.aspx[^]
regards,
Prakash.T
这篇关于如果勾选了复选框,如何更改选定的行comboBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!