private void SelectCalendarEvent_Shown(object sender, EventArgs e) { if (loadEventsInBackGround.IsBusy) { this.Enabled = false; loadingEventsForm = new LoadingEvents(); loadingEventsForm.StartPosition = FormStartPosition.CenterParent; loadingEventsForm.ShowDialog(this); } }
private void loadEvents(Boolean showLoading) { this.dataGridView1.DataSource = null; loadEventsInBackGround.RunWorkerAsync(dataGridView1); if (showLoading) { this.Enabled = false; loadingEventsForm = new LoadingEvents(); loadingEventsForm.StartPosition = FormStartPosition.CenterParent; loadingEventsForm.ShowDialog(this); } }
private void loadEventsInBackGround_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { this.Enabled = true; if (e.Result != null) { calendarInfo = e.Result as Tuple <SortableBindingList <IndianCalendarEvent>, DataTable>; this.dataGridView1.DataSource = calendarInfo.Item1; this.dataGridView1.Sort(this.dataGridView1.Columns[1], ListSortDirection.Descending); this.dataGridView1.Columns[this.dataGridView1.Columns.Count - 1].Visible = false; this.dataGridView1.Columns[this.dataGridView1.Columns.Count - 2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dataGridView1.Columns[1].DefaultCellStyle.Format = "MMMM dd, yyyy"; } if (loadingEventsForm != null) { loadingEventsForm.Close(); loadingEventsForm.Dispose(); loadingEventsForm = null; } }