标题:C#中提示信息:索引和长度必须引用该字符串内的位置。参数名:length,请各位 ...
只看楼主
luxury
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2011-3-4
结帖率:75%
已结贴  问题点数:20 回复次数:3 
C#中提示信息:索引和长度必须引用该字符串内的位置。参数名:length,请各位指教!
  private void GridViewMaster_SelectionChanged(object sender, EventArgs e)
        {
           try
            {
                DataGridViewRow grow = new DataGridViewRow();
                grow = GridViewMaster.CurrentRow;
                if (grow != null && grow.Cells["Id"].Value.ToString() != "")
                {
                    RowID = grow.Cells["Id"].Value.ToString();
                    DataRow[] drow = dtMain.Select("Id ='" + RowID + "'");
                    foreach (DataRow dr in drow)
                    {
                        setControlTextClear();
                        strBillNo = dr["BillNo"].ToString();

                        strTime = Convert.ToDateTime(dr["ProduceDate"].ToString());
                        strIsDept = dr["isDept"].ToString();

                        txt_OrderNo.Text = dr["BillNo"].ToString();

                        txt_Staff.Text = dr["StaffId"].ToString();
                        txt_StaffName.Text = dr["StaffName"].ToString();
                        dt_ProduceDate.Value = Convert.ToDateTime(dr["ProduceDate"].ToString());

                        txt_WorkOrderNo.Text = dr["WorkOrderNo"].ToString();
                        dt_ProduceDate.Value = Convert.ToDateTime(dr["ProduceDate"].ToString());
                        txt_ProduceQty.Text = dr["ProduceQty"].ToString();
                        txt_standard.Text = dr["standard"].ToString();
                        txt_ProduceTime.Text = dr["ProduceTime"].ToString();
                        txt_complement.Text = dr["complement"].ToString();
                        txt_Remark.Text = dr["remark"].ToString();
                        txt_BomId.Text = dr["BomId"].ToString();

                        txt_PartNo.Text = dr["PartNo"].ToString();
                        txt_PartName.Text = dr["PartName"].ToString();

                        txt_Approve.Text = dr["CurrentApprove"].ToString();
                        txt_ApproveStatus.Text = dr["Status"].ToString();
                        txt_AmountQty.Text = dr["AmountQty"].ToString();
                        txt_createper.Text = dr["createper"].ToString();
                        txt_createdate.Text = dr["createdate"].ToString();
                        txt_modifyper.Text = dr["modifyper"].ToString();
                        txt_modifydate.Text = dr["modifydate"].ToString();

                        if (IsStartApprove("ProduceTimeForSPY"))
                        {
                            string Obj = ClsAddFlowApprove.GetCurrentApproverStatus(txt_OrderNo.Text);
                            if (Obj == "待审核" || Obj == "待送审" || Obj == "" || Obj == "已退回")
                            {
                                tm_Add.Enabled = true;
                                cm_Approve.Enabled = true;
                                cm_MainAddDetail.Enabled = true;
                                if (Obj == "待审核")
                                { cm_Approve.Enabled = false; }
                            }
                            else
                            {
                                tm_Add.Enabled = false;
                                cm_Approve.Enabled = false;
                                cm_MainDelete.Enabled = false;
                                cm_MainAddDetail.Enabled = false;
                                cm_MainEdit.Enabled = false;

                            }//*/

                           
                        }
                        else
                        {
                            cm_Approve.Enabled = false;
                        }
                        if (state == operatestate.Isopt)
                            setControlTextClear();
                    }//foreach
                }//if
            }//try
            catch (Exception err)
            {
                MessageBox.Show("(108)提示信息:" + err.Message.ToString());
            }
        }
搜索更多相关主题的帖子: 字符串 null 
2011-03-15 19:22
luxury
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2011-3-4
得分:0 
各位大吓,帮帮忙啊
2011-03-19 16:38
zhp223
Rank: 5Rank: 5
等 级:职业侠客
帖 子:99
专家分:362
注 册:2010-3-21
得分:10 
是哪一行抛出的异常

日有所思,夜有所梦
2011-03-19 18:23
malgerz
Rank: 2
等 级:论坛游民
帖 子:9
专家分:43
注 册:2011-3-20
得分:10 
超出索引了吧?
2011-03-20 15:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-333867-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.046313 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved