DatagridVew中的TextBox控件不会在.TEXT属性上返回更新的值 [英] TextBox Control inside DatagridVew Does Not Return Updated Value on .TEXT property

查看:80
本文介绍了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属性上返回更新的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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