如何在vb.net中计算2个单元格

编程入门 行业动态 更新时间:2024-10-14 20:27:45
本文介绍了如何在vb中计算2个单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在寻找解决方案,但我找不到任何答案,请帮助我...... i我想要计算2个单元格显示总数..以下代码实际上很好并且只计算单行,我的问题是当我按下按钮2时我需要自动计算每一行......

Hi, Im searching for a solution but i can't find any answer, Please Help me... i have 2 cells that i want to compute and display the total.. the below code is actually fine and compute only single row, my problem is i need to compute every row automatically when i press the button2...

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click For i As Integer = 0 To DataGridView2.RowCount - 1 Dim xQty As Double = CDbl(DataGridView2.Rows(i).Cells(8).Value) Dim xPrc As Double = CDbl(DataGridView2.Rows(i).Cells(9).Value) DataGridView2.Rows(i).Cells(10).Value = xQty * xPrc Next End Sub

例如: b $ b

for example:

Product--------Price--------Quantity--------Total Amount Apple----------10.00-----------2---------------20 Banana---------20.00-----------3---------------20 Orange---------10.00------------5---------------30

第一行,当我更改价格时,苹果自动更改总金额并点击按钮.. 但第二排和第三排什么都没发生。我需要在一次点击中计算每一行......感谢先进的

the first row, apple automatically change the total amount when i change the price and click the button.. but the second and third row nothing happened. i need to compute every row in just one click... thanks in advanced

推荐答案

看看 Computed Columns [ ^ ] 或单元格事件 [ ^ ] 帮助你。 如果你真的需要按钮更新,请尝试调用Datagridview2.Refresh和/或Aftervalidate循环结束。 See if Computed Columns[^] or Cell events [^] help you. If you really need on button update, try calling Datagridview2.Refresh and/or Invalidate after the loop finishes.

Howdy All, 在for循环后尝试这个: Dim cm作为CurrencyManager = Direct Cast(datqaGridView2.BindingContext(dataGridView2.DataSource),_ CurrencyManager) cm.Refresh() regs, b $ b ron O。 Howdy All, Try this after the for loop: Dim cm As CurrencyManager = DirectCast(datqaGridView2.BindingContext(dataGridView2.DataSource), _ CurrencyManager) cm.Refresh() regs, ron O.

更多推荐

如何在vb.net中计算2个单元格

本文发布于:2023-11-21 23:40:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1615127.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元格   如何在   vb   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!