How to change a value in a text right after checking/unchecking a datagrid view "Checkbox" type of column?

Hello Experts

I'm using VP.NET to develop mmy Windows-Form application

I have a Datagrid View that has one of its columns of type "CheckBox". Upon runing my application, I go to that grid and I check/uncheck some of its records using that "Checkbox" type of column.

What I want to do now is: When I check/uncheck the intended rows, I need to change some text fiend value. What is the right Event that I can use to do so?

I tried the "CellContentClick", "CellClick", and "CellEnter", but they all do the change to that text fiend value after I move to - or select - another cell in the grid, what I want is to have that text field value change right after I check/uncheck the Checkbox column of the corresponding row.
Hussein ZahranAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

it_saigeDeveloperCommented:
You do want to use the CellContentClick event and here is how:
Form1.vb -
Public Class Form1
	ReadOnly Data As List(Of Item) = New List(Of Item)

	Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
		For i = 0 To 10 Step 1
			Data.Add(New Item() With {.Checker = (i Mod 2 = 0), .Text = String.Format("I am {0}", If(i Mod 2 = 0, "checked.", "not checked."))})
		Next

		DataGridView1.DataSource = Data
	End Sub

	Private Sub OnCellContentClicked(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
		If TypeOf sender Is DataGridView Then
			Dim dgv = DirectCast(sender, DataGridView)
			If dgv.Rows.Count() > 0 Then
				If TypeOf dgv(e.ColumnIndex, e.RowIndex) Is DataGridViewCheckBoxCell Then
					Dim chk = DirectCast(dgv(e.ColumnIndex, e.RowIndex), DataGridViewCheckBoxCell)
					dgv.Rows(e.RowIndex).Cells("Text").Value = String.Format("I am {0}", If(chk.GetEditedFormattedValue(e.RowIndex, Nothing) = True, "checked.", "not checked."))
				End If
			End If
		End If
	End Sub
End Class

Public Class Item
	Public Property Checker() As Boolean
	Public Property Text() As String
End Class

Open in new window

Form1.Designer.vb -
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
		Me.DataGridView1 = New System.Windows.Forms.DataGridView()
		CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
		Me.SuspendLayout()
		'
		'DataGridView1
		'
		Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
		Me.DataGridView1.Dock = System.Windows.Forms.DockStyle.Fill
		Me.DataGridView1.Location = New System.Drawing.Point(0, 0)
		Me.DataGridView1.Name = "DataGridView1"
		Me.DataGridView1.RowHeadersVisible = False
		Me.DataGridView1.Size = New System.Drawing.Size(233, 348)
		Me.DataGridView1.TabIndex = 0
		'
		'Form1
		'
		Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
		Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
		Me.ClientSize = New System.Drawing.Size(233, 348)
		Me.Controls.Add(Me.DataGridView1)
		Me.Name = "Form1"
		CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit()
		Me.ResumeLayout(False)

	End Sub
	Friend WithEvents DataGridView1 As System.Windows.Forms.DataGridView

End Class

Open in new window

Produces the following output -Initial loadAfter unchecking the first checkbox.-saige-
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.