Start a new project with 2 forms: one with a datagrid, a button and a
monthcalendar, and another form without controls.
Try this code in your form with the monthcalendar:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim frm As Form
frm = New Form2
frm.Show()
End Sub
Private Sub MonthCalendar1_DateChanged(ByVal sender As Object,
ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles
MonthCalendar1.DateChanged
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add("test")
dr = dt.NewRow()
dr.Item("test") = "test: " + Now.ToShortTimeString
DataGrid1.DataSource = dt
End Sub
you'll see after a while (every 2 minutes), the function is being
called, and the datagrid is filled with the testdata. Within my
application, the focus of the form is set, but if I make a new
application, the form with the monthcalendar is not getting the focus
indeed. I don't know why. Anyway, disable the monthcalendar refresh will
solve my problem.
Does anyone knows how to disable this monthcalendar refresh ? I've tried
to dynamically add/remove the datechanged handler from the
monthcalendar, but that didn't work.
Thanks,
Steven