vb.net datagridview列计算 [英] vb.net datagridview columns calculation

查看:96
本文介绍了vb.net datagridview列计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对所有程序员来说,特别好的一天。 heheheheh





如果你不介意,我只是想问一些东西,还有一些小代码。



例如我在vb.net中有一个datagridview和一个按钮



这是内容。



|数字|

--------

| 1 |

| 2 |

| 3 |

| 4 |

| 5 |

| 6 |

--------



假设我在datagridview中只有1列,我想发生这种情况,当我点击按钮时所有记录来自上述栏目将增加1.



|数量|

--------

| 2 |

| 3 |

| 4 |

| 5 |

| 6 |

| 7 |

--------



计算可能会这样做,如果我正确的话。我的意思是所有列我不是说如果我在上述列上有很多记录,如果它是1000+,只要它们都会增加1.



和计算完成后,输出将保存在同一行。更新方式。





提前

good day to all the programmers out there especially me. heheheheh


I just wanna ask something and also a little code if you don't mind.

For example i have a datagridview and a button in vb.net

and this are the contents.

|Number|
--------
|1 |
|2 |
|3 |
|4 |
|5 |
|6 |
--------

assuming that i have only 1 column in datagridview, i want to happen that when i click the button all the records from the said column will be increment by 1.

|Number|
--------
|2 |
|3 |
|4 |
|5 |
|6 |
|7 |
--------

calculation may do so if im right. i mean all the columns i doesnt mean if i have many records on the said column if it is 1000+ as long as all of them will increment by 1.

and after the calculation happens the output will be save on the same row. updated way.


ty in advance

推荐答案

你可以做这很容易。我假设您的网格绑定到某个数据集。如果没有,它只是网格中的值,所以你仍然可以做到。在按钮单击处理程序上,遍历数据源(或网格)的每一行并增加数字列中的值。完成后,重新绑定,并显示新值。 Access,SQLServer或Oracle ......它只是一个数据源,因此对UI中发生的事情无关紧要。如果您需要一个代码示例,请发布您现在填充网格的代码。
You can do this easily enough. I assume your grid is bound to some dataset. If not, it's just values in the grid, so you can still do it. On your button click handler, walk each row of your datasource (or grid) and increment the value in your Number column. When you're done, rebind, and the new values are displayed. Access, SQLServer or Oracle ... it's just a datasource, so that doesn't matter for what happens in the UI. If you need a code example, post the code of how you're populating your grid now.


这篇关于vb.net datagridview列计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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