数据集代码:
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add("DENOMINATION");
dt.Columns.Add("COUNT");
dt.Columns.Add("TOTAL");
dt.Rows.Add(new object[] { "1000", "0", "0" });
dt.Rows.Add(new object[] { "500", "0", "0" });
dt.Rows.Add(new object[] { "200", "0", "0" });
dt.Rows.Add(new object[] { "100", "0", "0" });
dt.Rows.Add(new object[] { "50", "0", "0" });
dt.Rows.Add(new object[] { "20", "0", "0" });
dt.Rows.Add(new object[] { "10", "0", "0" });
dt.Rows.Add(new object[] { "5", "0", "0" });
dt.Rows.Add(new object[] { "1", "0", "0" });
dt.Rows.Add(new object[] { "0.25", "0", "0" });
dt.Rows.Add(new object[] { "0.10", "0", "0" });
dt.Rows.Add(new object[] { "0.05", "0", "0" });
ds.Tables.Add(dt);
dgDENOM.AllowUpdate = true;
dgDENOM.SetDataBinding(dt, "", true);
在用户界面中:
DENOMINATION COUNT TOTAL
1000 0 0
500 0 0
我想要的实时/运行时间,列数将被修改,之后是total = denomination * count的值。我会把它放在db网格的事件上。
示例输出
DENOMINATION COUNT TOTAL
1000 5 5000
500 4 2000
答案 0 :(得分:0)
在c1TrueDbGrid中,您可以拥有未绑定的列 您使用C1TrueDBGrid.UnboundColumnFetch事件填充该列。
UnboundColumnFetchEventArgs类包含网格行,列和列索引的只读属性,以及值的读/写属性。
使用Value
属性为每一行设置单元格值 - 类似这样(未经测试):
private void c1TrueDBGrid1_UnboundColumnFetch(object sender, UnboundColumnFetchEventArgs e)
{
var row = e.Row;
var denomination = (int)grid.Columns["DENOMINATION"].CellValue(row);
var count = (int)grid.Columns["COUNT"].CellValue(row);
e.value = denomination * count;
}