如何在datagridview单元格上执行求和操作,并使用vb.net将结果存储在下一个单元格中 [英] how to perform sum operation on datagridview cells and store the result in next cell using vb.net

查看:108
本文介绍了如何在datagridview单元格上执行求和操作,并使用vb.net将结果存储在下一个单元格中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好





im在vb dot net中使用datagridview我想添加两个adjecent单元格并将结果存储在下一个细胞。那里的任何一个人帮我找到这个pb

im使用下面的代码



Hi all


i m using datagridview in vb dot net and i want to add the two adjecent cells and store the result in the next cell. any body there to help me sought out this pb
i m using the following code

For i As Integer = 0 To DataGridView1.Rows.Count - 1

            DataGridView1.Rows(i).Cells(2).Value = CStr(CInt(DataGridView1.Rows(i).Cells(0).Value) + CInt(DataGridView1.Rows(i).Cells(1).Value))
            DataGridView1.Rows(i).Cells(3).Value = CStr(CInt(DataGridView1.Rows(i).Cells(0).Value) - CInt(DataGridView1.Rows(i).Cells(1).Value))
            DataGridView1.Rows(i).Cells(4).Value = CStr(CInt(DataGridView1.Rows(i).Cells(0).Value) * CInt(DataGridView1.Rows(i).Cells(1).Value))
            DataGridView1.Rows(i).Cells(5).Value = CStr(CInt(DataGridView1.Rows(i).Cells(0).Value) / CInt(DataGridView1.Rows(i).Cells(1).Value))

        Next i

推荐答案

如果您使用网络应用程序,那么请输入代码...



首先取两个文本框为你数据...



一键添加



一个文本框结果... <按钮中的


你必须写下面的代码...



int frstnum;

int secnum;

int total;

frstnum = convert.parse(textbox1.text);

secnum = convert.parse (textbozx2.text);

total = frstnum + secnum;

textbox3.text = total.tostring();

meessagebox.show( 结果是+ textbox3.text +);
if ur using web application then go wth the code...

frst take two text boxes for ur data...

one button for for adding

one text box for result...

in button u have to write the below code...

int frstnum;
int secnum;
int total;
frstnum=convert.parse(textbox1.text);
secnum=convert.parse(textbozx2.text);
total=frstnum+secnum;
textbox3.text=total.tostring();
meessagebox.show("the result is + textbox3.text +");


这篇关于如何在datagridview单元格上执行求和操作,并使用vb.net将结果存储在下一个单元格中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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