1 Replies - 535 Views - Last Post: 08 December 2011 - 01:54 AM Rate Topic: -----

#1 naveed_786  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 306
  • Joined: 13-October 09

VB.NET CHECKBOX PROBLEM

Posted 08 December 2011 - 12:57 AM

I am auto generating data grid and I am using check box in Data grid View,
Now i am invoking check box state changed event but it produces the following error

Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

Here the code

    Private Sub PRNT_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles PRNT.CheckedChanged
    Some Stuff.
    End Sub


When i changes this line

Private PRNT As New DataGridViewCheckBoxColumn


To this

Private Withevents PRNT As New DataGridViewCheckBoxColumn



Then error changes

Event 'CheckedChanged' cannot be found.

What could be the problem.

Is This A Good Question/Topic? 0
  • +

Replies To: VB.NET CHECKBOX PROBLEM

#2 naveed_786  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 306
  • Joined: 13-October 09

Re: VB.NET CHECKBOX PROBLEM

Posted 08 December 2011 - 01:54 AM

By using This method i have resolved my problem

Private Sub DataGridView1_CurrentCellDirtyStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.CurrentCellDirtyStateChanged
        If DataGridView1.CurrentCell.ColumnIndex = 15 Then
            DataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit)
        End If
    End Sub

Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
        If e.ColumnIndex = 15 Then 
            Dim frm As New frm_wo_byid_rep(txtwono.Text)
            frm.Show()
        End If
    End Sub

This post has been edited by naveed_786: 08 December 2011 - 01:55 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1