读书人

DataGridView中的有关问题请有关问题

发布时间: 2012-01-21 21:31:43 作者: rapoo

DataGridView中的问题,请高手指点问题所在
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();
}

[解决办法]
帮顶
[解决办法]
dtAct.Rows[0].ItemArray[3].ToString().Trim();换其他的数字先试试,
[解决办法]
winform的.....帮你顶吧
[解决办法]
你赋值的时候弄混了combox的内部数据集,看看把原先的数据清空再赋值!

一起讨论,顶。。。。

读书人网 >C#

热点推荐