Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

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

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
 
Share this answer
 
v2
Declare at top
C#
TextBox txt1;

Cast the column to Textbox
C#
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);
	}
}

and Finally Raised the textchanged Event
C#
public void txt1_TextChanged(System.Object sender, System.EventArgs e)
{

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

}
 
Share this answer
 
Please help me the same with c# coding
 
Share this answer
 
Comments
Karwa_Vivek 10-Feb-15 1:49am    
Check the C# version. Hope this helps u.
for conversion you can visit.
http://converter.telerik.com/
Karwa_Vivek 10-Feb-15 1:52am    
Post you Comments in
Have a Question or Comment ?
Section.
Not Here, this space is meant for Solutions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900