简体   繁体   English

发生mscorlib.dll错误时发生未处理的“System.StackOverflowException”类型异常?

[英]An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll error occurred?

Am getting error Unbound Expression. 我收到错误Unbound Expression。 I Created a new column & Unbounded Expression on Runtime. 我在运行时创建了一个新列和Unbounded Expression。 I get a particular cell values(GetRowCellValue) from gridview and try to change that unbound expression column with new value(SetRowCellValue). 我从gridview获取特定的单元格值(GetRowCellValue)并尝试使用新值(SetRowCellValue)更改该未绑定的表达式列。 But error shown whats my mistake ? 但错误显示我的错误? Help me. 帮我。

This is my Code. 这是我的代码。

private void unbound2_Load(object sender, EventArgs e)
    {
        // TODO: This line of code loads data into the 'orionSystemDataSet.Test_Product' table. You can move, or remove it, as needed.
        this.test_ProductTableAdapter.Fill(this.orionSystemDataSet.Test_Product);
        // TODO: This line of code loads data into the 'orionSystemDataSet.Test_Gridview' table. You can move, or remove it, as needed.
        this.test_GridviewTableAdapter.Fill(this.orionSystemDataSet.Test_Gridview);


        var product = repositoryItemGridLookUpEdit1.View.Columns.AddField("Type");
        product.Visible = true;


        //create unbound column in form load
        unboundcreate();

    }

    private void unboundcreate()
    {
        gridControl1.ForceInitialize();

        GridColumn unbColumn = gridView1.Columns.AddField("PriceQuantity");
        unbColumn.Caption = "PricQuan";
        unbColumn.VisibleIndex = gridView1.Columns.Count;
        unbColumn.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
        unbColumn.OptionsColumn.AllowEdit = false;
        unbColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
        unbColumn.DisplayFormat.FormatString = "c";
        unbColumn.AppearanceCell.BackColor = Color.LemonChiffon;
        unbColumn.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
        unbColumn.UnboundExpression = "[Quantity] * [Each]";

    }

Code to get value & set value 获取价值和设定价值的代码

 private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
    {

            GridView view = sender as GridView;


            if (e.Column.FieldName == "PriceQuantity" && e.IsGetData)
            {
                //e.Value = getTotalValue(view, e.ListSourceRowIndex);
                calfun();
            }
            else
            {
                // nothing
            }

    }


    private void calfun()
    {
        if (gridView1.FocusedRowHandle >= 1)
        {

            string temp = "Discount";
            //string dis = TXE_Gettype.Text.ToString();
            object objec = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["Type"]);
            string dis = objec.ToString();

            if (dis == temp)
            {
                object obj = gridView1.GetRowCellValue(gridView1.FocusedRowHandle - 1, gridView1.Columns["Each"]);

                int aa = Convert.ToInt32(obj);
                //textEdit1.Text = aa.ToString();

                object obj1 = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["Each"]);

                int a = Convert.ToInt32(obj1);
                int b = aa;

                int c = a * b;

                //textEdit2.Text = c.ToString();

                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["PriceQuantity"], c);
            }
        }
        else
        {
            }
    }

Help me Please I want to get & set value 帮助我请我想获得并设定价值

The last couple of frames of your stacktrace could be usefull... even with all this code, we can only speculate. 堆栈跟踪的最后几帧可能很有用......即使使用了所有这些代码,我们也只能推测。

But I agree with JensKloster's comment: DevExpress unbound columns are made to display unbound columns (computed, from others, then). 但我同意JensKloster的评论:DevExpress未绑定列用于显示未绑定列(然后从其他列计算)。

The event is here to make you compute this value. 此事件可让您计算此值。 It is called each time you change something in your row. 每次更改行中的某些内容时都会调用它。 Thus, calling setvalue from it will cause the method to call it itself. 因此,从中调用setvalue将导致该方法自己调用它。 (=> stack overflow exception) (=>堆栈溢出异常)

Use e.Value = myValue to set your value: 使用e.Value = myValue设置您的值:

e.Value = c;

instead of 代替

gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["PriceQuantity"], c);

where e is the DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs given as an argument of your event. 其中e是作为事件参数给出的DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs。

edit: Moreover, I guess that when using gridView1.FocusedRowHandle , you were refering to e.RowHandle ? 编辑:另外,我想,当使用gridView1.FocusedRowHandle ,你指的e.RowHandle See this to see what is given to you when this event is called. 看到这个 ,看看调用此事件时给你的是什么。

edit2: why using custom mechanisms if you just want to multiply two columns ? edit2:为什么要使用自定义机制,如果你只想乘以两列? unbColumn.UnboundExpression = "[Quantity] * [Each]"; is sufficient, isnt it ? 已经足够了,不是吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 mscorlib.dll中发生了未处理的“System.StackOverflowException”类型异常 - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll 错误:mscorlib.dll中发生了'System.StackOverflowException'类型的未处理异常 - Error: An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll 调用递归函数期间,mscorlib.dll中发生了'System.StackOverflowException'类型的未处理异常 - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll during calling recursive function RedisClientManager,mscorlib.dll中发生未处理的“System.StackOverflowException”类型异常 - RedisClientManager, An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll C# - 实体框架 - mscorlib.dll中发生未处理的“System.StackOverflowException”类型异常 - C# - Entity Framework - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll 在启动我的MVC3应用程序时,在mscorlib.dll中出现“类型'System.StackOverflowException'的未处理异常”? - On starting my MVC3 application, getting “An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll”? WPF telerik TreeView控件中的mscorlib.dll发生类型为'System.StackOverflowException'的未处理异常 - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll in WPF telerik TreeView Control 局部视图:mscorlib.dll中发生了'System.StackOverflowException'类型的未处理异常 - Partial View: An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll 对三个整数数组进行排序时,mscorlib.dll中发生了类型为'System.StackOverflowException'的未处理异常 - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll when sorting array of three integers mscorlib.dll asp.net-mvc中发生类型为'System.StackOverflowException'的未处理异常 - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll asp.net-mvc
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM