錯誤無約束表達式。我在運行時創建了一個新列& Unbounded Expression。我從gridview中獲取一個特定的單元格值(GetRowCellValue),並嘗試用新值(SetRowCellValue)更改該未綁定的表達式列。但錯誤顯示我的錯誤是什麼?幫我。發生mscorlib.dll錯誤時出現未處理的「System.StackOverflowException」類型異常?
這是我的代碼。
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]";
}
代碼來獲得價值&設定值
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
{
}
}
幫助我,請我希望得到&設定值
我的猜測是,它是你的'gridView1.SetRowCellValue'調用導致'gridView1_CustomUnboundColumnData'事件被稱爲 –
喜延,如果我修改SetRowCellValue到gridView1_CustomUnboundColumnData它顯示錯誤像「CustomUnboundColumnData事件只能出現左手邊+ =或= +「 – Srihari
yesc:D呵呵,你爲什麼要那樣做?而不是使用'gridView1 ...'嘗試看看是否可以使用'e'變量.. –