DataGridViewComboBoxColumn和DataGridView
我现在想在DataGridView中加一个combox这个控件不管是System.windwos.forms.combox还是DataGridViewComboBoxColumn
我要想达到的功能就是
当单击一下DataGridView中的某单元格时,出现一个combox供我选择,这可以达到,
当选择后,我要赋值给DataGridView中的当前行的某些列的单元格,也可以达到问题所在:
赋值不稳定,有时明明选择combox中的值后不移开,可以看到赋值,但把鼠标移开后,赋值不见了.
有时会崩了,赋值多了或是不停赋值,整个DataGridView会崩导至系统崩!错误提示说是什么数组超出范围的东东请高手分析原因和指出好的方法解决此问题.以下为赋值代码
if(this.cdgvAc.CurrentRow.Cells["WorkOrderCode"]!= null )
this.cdgvAc.CurrentRow.Cells["WorkOrderCode"].Value = this.txtGxCode.Text.Trim();//工序编号 if(this.cdgvAc.CurrentRow.Cells["ActionCode"]!=null )
this.cdgvAc.CurrentRow.Cells["ActionCode"].Value = dtAct.Rows[0].ItemArray[1].ToString().Trim();//动作代码 if(this.cdgvAc.CurrentRow.Cells["ActionName"]!=null)
this.cdgvAc.CurrentRow.Cells["ActionName"].Value = dtAct.Rows[0].ItemArray[2].ToString().Trim();//动作名称 if(this.cdgvAc.CurrentRow.Cells["ActionOrder"]!=null )
this.cdgvAc.CurrentRow.Cells["ActionOrder"].Value = dtAct.Rows[0].ItemArray[4].ToString().Trim();//动作顺序 if (dtAct.Rows[0].ItemArray[5].ToString().Trim() == "False")
{
if(this.cdgvAc.CurrentRow.Cells["ManualTMU"]!=null)
this.cdgvAc.CurrentRow.Cells["ManualTMU"].Value = dtAct.Rows[0].ItemArray[3].ToString().Trim();
}
else
{
if(this.cdgvAc.CurrentRow.Cells["MachineTMU"]!=null)
this.cdgvAc.CurrentRow.Cells["MachineTMU"].Value = dtAct.Rows[0].ItemArray[3].ToString().Trim();
}
我现在想在DataGridView中加一个combox这个控件不管是System.windwos.forms.combox还是DataGridViewComboBoxColumn
我要想达到的功能就是
当单击一下DataGridView中的某单元格时,出现一个combox供我选择,这可以达到,
当选择后,我要赋值给DataGridView中的当前行的某些列的单元格,也可以达到问题所在:
赋值不稳定,有时明明选择combox中的值后不移开,可以看到赋值,但把鼠标移开后,赋值不见了.
有时会崩了,赋值多了或是不停赋值,整个DataGridView会崩导至系统崩!错误提示说是什么数组超出范围的东东请高手分析原因和指出好的方法解决此问题.以下为赋值代码
if(this.cdgvAc.CurrentRow.Cells["WorkOrderCode"]!= null )
this.cdgvAc.CurrentRow.Cells["WorkOrderCode"].Value = this.txtGxCode.Text.Trim();//工序编号 if(this.cdgvAc.CurrentRow.Cells["ActionCode"]!=null )
this.cdgvAc.CurrentRow.Cells["ActionCode"].Value = dtAct.Rows[0].ItemArray[1].ToString().Trim();//动作代码 if(this.cdgvAc.CurrentRow.Cells["ActionName"]!=null)
this.cdgvAc.CurrentRow.Cells["ActionName"].Value = dtAct.Rows[0].ItemArray[2].ToString().Trim();//动作名称 if(this.cdgvAc.CurrentRow.Cells["ActionOrder"]!=null )
this.cdgvAc.CurrentRow.Cells["ActionOrder"].Value = dtAct.Rows[0].ItemArray[4].ToString().Trim();//动作顺序 if (dtAct.Rows[0].ItemArray[5].ToString().Trim() == "False")
{
if(this.cdgvAc.CurrentRow.Cells["ManualTMU"]!=null)
this.cdgvAc.CurrentRow.Cells["ManualTMU"].Value = dtAct.Rows[0].ItemArray[3].ToString().Trim();
}
else
{
if(this.cdgvAc.CurrentRow.Cells["MachineTMU"]!=null)
this.cdgvAc.CurrentRow.Cells["MachineTMU"].Value = dtAct.Rows[0].ItemArray[3].ToString().Trim();
}
解决方案 »
- c#如何获取网页的内容
- winwordcontrol 控件使用问题汇总(待解决)
- 高分求助!!C# 打印panel中的全部内容,panel有滚动条,panel中有一个DataGridView控件也有滚动条.
- C#中调用C++的dll找不到函数的入口点
- dotNetCharting的问题
- Dundas chart 数据绑定的问题!
- 高分求解!C#中,如何去掉文件的只读属性?
- table 导出到Excel "0"丢失
- 如何修改其他程序窗口的标题啊,帮帮忙啊,谢谢了。
- 关于数据库查询的问题!
- 下面的代码能编译过,用DATASET 和 MySqlDataAdapter 操作数据库 , 请问为什么不能插入一个记录到数据库呢
- 如何将Shift-JIS编码转换为字符?
System.ArgumentOutOfRangeException 指定的参灵数已超出有效的范围
赋值的值的从其它地方拿过来的
再放到DataGridView行中,DataGridView的数据源已和表绑定,和赋值数据是不同的表