Vb.net文本框到datagridview并添加价格现有值 [英] Vb.net textbox to datagridview and add price existing value
本文介绍了Vb.net文本框到datagridview并添加价格现有值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Dim table As New DataTable
da.Fill(table)
table.Rows.Add(TextBox1.Text,TextBox2.Text,TextBox3.Text,TextBox5。文字)
DataGridView1.DataSource = table
我尝试过:
如何在文本框中添加datagridview中的值,我想添加相同的产品价格10.如果已添加,则单元格总数为20.
如何实现这个功能?
解决方案
我在评论中写道:
Dim mySum as double = cdbl (TextBox1.Text)+ cdbl (TextBox2.Text)+ cdbl ( TextBox3.Text)+ cdbl(TextBox5.Text)
table.Rows.Add(mySum.toString)
但请注意:
每个文本框值必须能够被转换。如果有可能存在非十进制值,则应该处理它。
结果mySum没有格式化 - 但toString使您能够执行此操作 - 请参阅MSDN-Help for this ...
Dim table As New DataTable
da.Fill(table)
table.Rows.Add(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox5.Text)
DataGridView1.DataSource = table
What I have tried:
How to add value in datagridview from textbox and I want to add same product price 10. If they are already added then cells total become 20.
How to achieve this functionality?
解决方案
As I wrote in my Comment :
Dim mySum as double = cdbl(TextBox1.Text) + cdbl(TextBox2.Text) + cdbl(TextBox3.Text) +cdbl(TextBox5.Text) table.Rows.Add(mySum.toString)
But note :
Each Textbox-Value MUST be able to be converted. If it is possible that there is a non-decimal value in it you should handle it.
the Result mySum has no Formatting - but toString gives you the ability to do this - see MSDN-Help for this ...
这篇关于Vb.net文本框到datagridview并添加价格现有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文