DatagridVew中的TextBox控件不会在.TEXT属性上返回更新的值

编程入门 行业动态 更新时间:2024-10-21 14:30:34
本文介绍了DatagridVew中的TextBox控件不会在.TEXT属性上返回更新的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

i已准备好一个Datagrid用于更新产品价格和一次性全部更新, 因为我已经采取了Textbox在Datagrid中控制, 我的数据看起来像这样... ItemName,PurchaseRate,SaleRate, PurchaseRateWithvat,SaleRateWithVat 我已经输入PurchaseRateWithVat,它计算PurchaseRateWithoutVat并在一次性更改数据库中的所有价格更新后。 但主要问题是,当我更改文本框的值并转到更改后的值时,它返回 oldValue + newvalue ,如(0.00,80)这里0.00是旧的和80是更新值, i只需更新价值, 请帮助我, 先谢谢。

Hi, i have Prepared one Datagrid for Updating Products Price and Update all in one shot, for that i have taken Textbox Control inside Datagrid, My data Looks like this... ItemName , PurchaseRate , SaleRate , PurchaseRateWithvat , SaleRateWithVat I have Enter PurchaseRateWithVat from That it''s calculate PurchaseRateWithoutVat and after Changing all the Price Update in Database in One Shot. but Main Problem is that when i change the value of textbox and tring to retrive changed value then it returns oldValue+newvalue like (0.00,80) here 0.00 is old and 80 is updated value, i need only updated value, please help me, Thanks in Advance.

推荐答案

大家好, 我假设你已经实现了IDataGridViewEditingControl来托管T DataGridView控件中的extbox。所以在这种情况下你也可能也派生了TextBox控件。 你只需要覆盖On TextChanged事件并解析文本。它会给你更新的价值。 请参考下面的代码块。 Hi All, I assume that you have implemented the IDataGridViewEditingControl to host the Textbox inside the DataGridView control. so in that case you might have also derived the TextBox control as well. You just need to override On TextChanged event and parse the text. it will give you updated vlaue. Please refer the below code block. protected override void OnTextChanged(EventArgs e) { base.OnTextChanged(e); DataGridViewColumn dataGridViewColumn = this.dataGridView.Columns[this.dataGridView.CurrentCell.ColumnIndex]; ISwitchRowStatement swtRowStatement = this.dataGridView["ColRow", this.dataGridView.CurrentCell.RowIndex].Tag as ISwitchRowStatement; float value; if (float.TryParse(this.Text, out value)) { this.dataGridView["ColumnHystersis", this.dataGridView.CurrentCell.RowIndex].Value = value; } }

如果以上解决方案不是,请发布代码为你工作。 问候, Sathish

Please post the code if above solution is not working for you. Regards, Sathish

更多推荐

DatagridVew中的TextBox控件不会在.TEXT属性上返回更新的值

本文发布于:2023-11-11 23:26:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579828.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:会在   控件   属性   DatagridVew   TextBox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!