gridview 2 column1和2来自c#windows应用程序中的第3列 [英] gridview 2 column1 and 2 comes column 3 in c# windows application

查看:86
本文介绍了gridview 2 column1和2来自c#windows应用程序中的第3列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi



i我选择网格视图中的表 openstk,entry stck和totalstack


运行时
openstack 列中显示网格默认值,并在运行时数据网格中输入 entrystck 列中的值



我期望在运行时网格中产生列 totalstack = openstack + entrystck



建议我这些代码的示例



朋友们清除这些计算方法这会影响N没有行我有175个库存商品



谢谢

hi

i am select the table in grid view openstk,entry stck and totalstack columns

in runtime displays grid default value in openstack column and enter the value in entrystck column in runtime datagrid

what i am expecting in runtime grid resulting in column totalstack = openstack+entrystck

suggest me example for these code

friends anyone clear these calculation method this affects N no of rows i have 175 stock items

thanks

推荐答案

您好,



尝试使用RowDataBound事件。使用以下代码:



Hi,

Try using the RowDataBound Event. Use the following code:

protected void gridview_RowDataBound(object sender, GridViewRowEventArgs e)
{   
   //Get data row view
   DataRowView drview = e.Row.DataItem as DataRowView;
   if (e.Row.RowType == DataControlRowType.DataRow)
   {
      int value1 = Int32.Parse(e.Row.Cells[0].Text);
      int value2 = Int32.Parse(e.Row.Cells[1].Text);
      e.Row.Cells[2].Text = Convert.ToString(value1+ value2);
   }
}





希望这会有所帮助并给你一个想法:)



问候,

Praneet



Hope this helps and gives you an idea :)

Regards,
Praneet


in DataGridView.CellEndEdit Event [ ^ ]计算并设置totalstack单元格值。 />
示例代码:

in DataGridView.CellEndEdit Event[^] calculate and set the totalstack cell value.
Sample code:
int val1 = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value);
int val2 = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[1].Value);
dataGridView1.Rows[e.RowIndex].Cells[2].Value = (val1 + val2).ToString();



参考: [C#] DataGridView如何求和单元格 [ ^ ]


这篇关于gridview 2 column1和2来自c#windows应用程序中的第3列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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