未绑定列不显示结果 [英] unbound column doesn't show result

查看:103
本文介绍了未绑定列不显示结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





VB newbe正在寻求帮助。 :-)



我有一个8列的数据网格(id,ean,名称,描述,价格,总价,间隔栏和增值税)。



我想在显示价格公司的数据网格中显示一个计算列。增值税(总价)

所以我在索引5上创建了一个未绑定的列,当我尝试填充该列时,它没有显示结果。

Hi,

VB newbe looking for some help. :-)

I have a datagrid with 8 columns (id, ean, name, description, price, totalprice, a spacer column and vat).

I like to show a calculated column in a datagrid showing price inc. vat (totalprice)
So i created a unbound column wich is on index 5 and when i try to populate that column it doesn''t show the results.

For Each r As DataGridViewRow In Me.dataGridProducts.Rows
    TotaalPrijs = r.Cells(4).Value + (r.Cells(4).Value * r.Cells(8).Value / 100)
    r.Cells(5).Value = totaalPrijs
Next



当我使用索引时在任何其他绑定列中,它显示错误列中的结果


When i use the index of any other bound column it shows me the result in the wrong column

For Each r As DataGridViewRow In Me.dataGridProducts.Rows
    TotaalPrijs = r.Cells(4).Value + (r.Cells(4).Value * r.Cells(8).Value / 100)
    r.Cells(6).Value = totaalPrijs
Next



任何帮助都是appriciated


Any help would be appriciated

推荐答案

它在C#中希望这有帮助



Its in C# hope this helps

private void buildDataTable() {

    DataTable dt = new DataTable("test");
    dt.Columns.Add("col1", typeof(int));
    dt.Columns.Add("col2", typeof(int));
    dt.Columns.Add("col3", typeof(int));

    dt.Rows.Add(1, 2);
    dt.Rows.Add(2, 3);
    dt.Rows.Add(3, 4);
    dt.Rows.Add(4, 5);

    foreach (DataRow dr in dt.Rows) {
        dr[2] = (int)dr[0] + (((int)dr[1] * 100) / 100);
    }
    dgv1.DataSource = dt;
}

private void addColunmAndValue() {

    dgv1.Columns.Add("Col4", "Col4");
    foreach (DataGridViewRow dr in dgv1.Rows) {
        DataGridViewCellCollection dc = dr.Cells;
        if (!dr.IsNewRow) {
            dc[3].Value = (int)dc[2].Value + ((int)dc[1].Value * 100);
        }
    }
}


这篇关于未绑定列不显示结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆