替换VB.Net中datagridview中的值 [英] replace values in datagridview in VB.Net

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

问题描述

大家好,

我正在使用VB.net的datagridview中的数据执行一些统计计算.我的datagridview连接到存储我所有数据的Access数据库.我将使用一组指令将数据从访问权限调用到datagridview中.完成一些计算后,我需要用其他值替换datagridview中的值.我无法弄清楚该如何做.

我的datagridview中的样本数据是

X1_ X2_ X3_ Yj
1_ 1_ 2_ 5
1_ 2_ 1_ 6
2_ 1_ 1_ 7
2_ 2_ 2_ 8

(PS:我在本文中使用下划线来正确设置数据格式.打分与我在Datagridview中的数据无关)

在对该数据进行少量计算之后,我想替换X1,X2和X3列下的值.例如,我想将X1下的1替换为50,将X1下的2替换为2.请在下面找到映射表

X1 1替换为50
X1 2替换为100
X2 1替换为75
X2 2替换机智25
X3 1替换为-1
X3 2替换为1


如果我能对此有所了解,将非常有帮助.
(对不起,我是一个新程序员)

在此先感谢

Hello All,

I am working on performing some statistical calculations with data in datagridview in VB.net. MY datagridview is connected to an Access data base where all my data is stored. Using a set of instructions I will call the data from access into datagridview. After performing some calculations I need to replace values in my datagridview with other values. I am unable to figure out how to do this.

Sample data in my datagridview is

X1_ X2_ X3_ Yj
1_ 1_ 2_ 5
1_ 2_ 1_ 6
2_ 1_ 1_ 7
2_ 2_ 2_ 8

(PS: I am using the underscore to make the data format properly in this post. Under score has nothing to do with my data in Datagridview)

After few calculations in this data I would like to replace values under columns X1, X2 and X3. For example I want to replace the 1''s under X1 with 50 and the 2''s under X1 with 2. Please find the mapping table below

X1 1 replace with 50
X1 2 replace with 100
X2 1 replace with 75
X2 2 replace wit 25
X3 1 replace with -1
X3 2 replace with 1


If I can get a heads up about this it will be very helpful.
(Pardon my jargon I am a new programmer)

Thanks in advance

推荐答案

inam,avi写道:
inam,avi wrote:

(请原谅我的行话是一个新程序员)

(Pardon my jargon I am a new programmer)



那么这对您来说太复杂了.我相信您正在上一堂课,如果您为此获得报酬,那是完全可耻的.您应该向老师寻求具体帮助,但是使用任何数据绑定控件的答案是更新数据,然后再次绑定.



Then this is way too complex for you. I trust you''re doing this for a class, if you''re being paid for it, it''s an utter disgrace. You should talk to your teacher for specific help, but the answer with any data bound control, is to update your data and then bind again.


在我看来,您想更改数据本身(您仍然将其保存在内存中),然后只需刷新/重新绑定DataGridView.

因此,您需要遍历数据集中的行,更改值,然后鲍勃是您的叔叔.
It seems to me that you would want to change the data itself (you still have it in memory), and then simply refresh/rebind the DataGridView.

So, you''d need to iterate through the rows in the dataset, change the values, and Bob''s your uncle.


这篇关于替换VB.Net中datagridview中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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