Private Sub dgMtnc_MouseClick(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgMtnc.MouseClick
Try
'Get size and location of grid cell
Dim cb As New System.Drawing.Rectangle() 'cell bounds
'dgMtnc.CurrentCell.ColumnNumber = 0
If dgMtnc.CurrentCell.ColumnIndex() = 0 Then 'Column 0 clicked
If Not cc.Tag = "Open" Then 'Do once
'cc.Size = New Size(30, 30)
cb = dgMtnc.CurrentCell.ContentBounds
'GetCellDisplayRectangle, cell bounds
cc.Location = New Point(cb.X, cb.Y)
'Location for month control
dgMtnc.Controls.Add(cc)
'Add the month control
cc.Tag = "Open"
cc.BringToFront()
'must add the events you want to use
AddHandler cc.DateSelected, AddressOf cc_DateSelected
Else
'Same as above "without addhandler if control is already open
'cb = dgTest.GetCellBounds(dgTest.CurrentRowIndex, 0)
cb = dgMtnc.CurrentCell.ContentBounds
cc.Location = New Point(cb.X, cb.Y)
cc.BringToFront()
cc.Tag = "Open"
End If
cc.Show() 'Show the control
Else : cc.Hide()
End If
Catch ex As Exception
End Try
End Sub
Private Sub cc_DateSelected(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles cc.DateSelected
Try
'Put selected date in selected cell then hide control
dgMtnc.CurrentRow.Cells(0).Value = DirectCast(cc.SelectionStart.Date, Date)
cc.Hide()
Catch ex As Exception
End Try
End Sub