Hi William,
William Fields (4/11/2011)
If I take this route, what event in the form or the DBI control, should I use? I guess I would need an event that fires after the "ParentFormLoading" event, and one that fires when the form controls are all available, but before the form becomes visible.What I usually do to get the effect of loading the data after the form is shown is use a timer control with a an interval of 500 or more based on your needs, an SF Wait Window control to let the user know that the data is being loaded and a Background Worker to actually load the data.
Here is a sample of the events I use loading data for DevExpress scheduler:
Protected Overrides Sub OnLoad(e As System.EventArgs)
MyBase.OnLoad(e)
With Me.SchedulerControl1
'-- Setup working hours from 9:30am to 8:00pm
.DayView.ShowWorkTimeOnly = True
.DayView.WorkTime.Start = New TimeSpan(0, 9, 30, 0)
.DayView.WorkTime.End = New TimeSpan(0, 20, 0, 0)
.DayView.AppointmentDisplayOptions.StartTimeVisibility = AppointmentTimeVisibility.Never
.DayView.AppointmentDisplayOptions.EndTimeVisibility = AppointmentTimeVisibility.Never
.WeekView.AppointmentDisplayOptions.StartTimeVisibility = AppointmentTimeVisibility.Never
.WeekView.AppointmentDisplayOptions.EndTimeVisibility = AppointmentTimeVisibility.Never
.WorkWeekView.AppointmentDisplayOptions.StartTimeVisibility = AppointmentTimeVisibility.Never
.WorkWeekView.AppointmentDisplayOptions.EndTimeVisibility = AppointmentTimeVisibility.Never
.MonthView.AppointmentDisplayOptions.StartTimeVisibility = AppointmentTimeVisibility.Never
.MonthView.AppointmentDisplayOptions.EndTimeVisibility = AppointmentTimeVisibility.Never
'-- Disable Create, Delete, Copy and multi-select appointments.
' The appointments can only be moved from one date to another.
' Other data changes should only be made via the Service Call maintenance form.
.OptionsCustomization.AllowAppointmentCreate = UsedAppointmentType.None
.OptionsCustomization.AllowAppointmentDelete = UsedAppointmentType.None
.OptionsCustomization.AllowAppointmentCopy = UsedAppointmentType.None
.OptionsCustomization.AllowAppointmentMultiSelect = False
.OptionsCustomization.AllowInplaceEditor = False
'-- Show today's appointments
.Start = Now.Date
End With
'-- Start the timer that will load the data for the schedule.
' A timer is used to show the empty scheduler control and then the data.
Me.ScheduleDataLoadTimer.Start()
End Sub
Private Sub ScheduleDataLoadTimer_Tick(sender As System.Object, e As System.EventArgs) Handles ScheduleDataLoadTimer.Tick
Me.ScheduleDataLoadTimer.Stop()
Me.LoadAllDataForSchedulerAsync()
End Sub
Private Sub LoadAllDataForSchedulerAsync()
'-- Use a background worker to allow the form to show complete showing, then
' use the Wait Window to show the message that the data is being loaded.
With Me.WaitWindow1
.ShowInScreen = False
.WaitWindowLocation = MicroFour.StrataFrame.Messaging.MessagingCardinalPosition.Center
.Title = My.Application.Info.Title
.Message = "Please wait, loading scheduler records..."
.ShowWaitWindow()
End With
Me.Cursor = Cursors.WaitCursor
Me.bwMainData.RunWorkerAsync()
End Sub
Private Sub bwMainData_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles bwMainData.DoWork
Me.LoadAllDataForScheduler(Me, New EventArgs)
End Sub
Private Sub bwMainData_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bwMainData.RunWorkerCompleted
Me.WaitWindow1.HideWaitWindow()
Me.Cursor = Cursors.Default
End Sub
For your DBI control, you may do the following:
- Load all your data into your BO at once using the FillMultipleDataTables method.
- Loop all the BO using the bo.GetEnumerable() to create your schedule collection, in this process use the DBI control Tag property or some other to save the Primary Key of the record. Pretty much as the ListView does internally, this way you can always navigate to the correct record in the BO via the scheduler events.
Hope above code can give you some ideas on handling this situation.
Edhy Rijo