From: Rob W on

I have a connectmenustrip item that when clicked runs the following code
(see below)

Now if the event is called by the button i.e. cmdDeleteingBooking.Click the
linq query returns the appropriate value.

However when called by cntMnuCancelBookingItem.Click is returns 0 even if a
checkbox is of 'TRUE' value.

Debugging shows the code runs exactly the same code (which loops around rows
in a datagridview checking if the checkbox has been checked).

Could someone explain the reasoning why the same code would return different

Private Sub cmdDeleteingBooking_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdDeleteingBooking.Click,

MessageBox.Show("In here")

'Linq statement to count number of rows where
Dim bookingsSelectedDeletion As Integer = (From bookings In
dgvBookings.Rows _
Select bookings _
Where CType(DirectCast(bookings,
DataGridViewRow).Cells("selectColumn").FormattedValue, Boolean) =

MessageBox.Show("Number is " & bookingsSelectedDeletion.ToString)

End sub