DataGridview在Cell的textChanged事件上自动填充单元格值 [英] DataGridview auto fill cell value on textChanged event of Cell

查看:237
本文介绍了DataGridview在Cell的textChanged事件上自动填充单元格值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个

DataGridview有

四个Coloumns

SlNo InvoiceNo应付税款



am在按钮上以编程方式添加行单击

然后设置EditonEnter模式。

在列表上逐个填充列

和textChanged税栏中的事件

获取应付款栏上的值

等于金额税。



但问题是在textThanged事件中Tax

应付款单元格未获得所需的值。

在输入之后支付单元格然后在选项卡上

获得价值。



如何解决此问题我希望在文本更改或当我更改

税单位值应付款单元格必须获取金额单元格的值 - 税单位。

请协助。我已经将税单元素转换为文本框。

I have a
DataGridview having
Four Coloumns
SlNo InvoiceNo Amount Tax Payable

am Adding rows programatically on Button Click
and then have set EditonEnter mode.
Filling the Columns one by one on tab
and on textChanged Event of "Tax" column
getting the Values on Payable Column
which is equal to Amount-Tax.

But the problem is that on textChanged event of "Tax"
the Payable cell is not getting the required value.
where as after Entering on that Payable Cell and then after on tab
its getting the Value.

How to solve this Issue I want that on text changed or when i change the
Tax cells value Payable cell must get the value that is Amount cell - tax cell.
Please Assist. I have Cast the Tax cell to textbox.

推荐答案

确定我有工作

在顶部声明

ok i got It working
Declared at top
Dim WithEvents txt1 As TextBox



将列投射到文本框


Cast the column to Textbox

Private Sub dgvInvoice_EditingControlShowing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dgvInvoice.EditingControlShowing
        Try

            If dgvInvoice.CurrentCell.ColumnIndex = 3 Then
                If TypeOf e.Control Is TextBox Then
                    txt1 = DirectCast(e.Control, TextBox)
                End If
            End If
            

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub



并最终提高了textchanged事件


and Finally Raised the textchanged Event

Public Sub txt1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt1.TextChanged

       
            If dgvInvoice.CurrentCell.ColumnIndex = 3 Then
                --- DONE WHAT I WANTED
            End If

    End Sub


在顶部声明

Declare at top
TextBox txt1;



将列投射到文本框


Cast the column to Textbox

private void dgvInvoice_EditingControlShowing(System.Object sender, System.Windows.Forms.DataGridViewEditingControlShowingEventArgs e)
{
	try {

		if (dgvInvoice.CurrentCell.ColumnIndex == 3) {
			if (e.Control is TextBox) {
				txt1 = (TextBox)e.Control;
			}
		}


	} catch (Exception ex) {
		MsgBox(ex.Message);
	}
}



和最后提出了textchanged事件


and Finally Raised the textchanged Event

public void txt1_TextChanged(System.Object sender, System.EventArgs e)
{

	if (dgvInvoice.CurrentCell.ColumnIndex == 3)
	 {
		----DO what you want
	}

}


请用c#编码来帮助我


这篇关于DataGridview在Cell的textChanged事件上自动填充单元格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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