Click here to Skip to main content
15,885,767 members
Home / Discussions / Windows Forms
   

Windows Forms

 
QuestionHow to print data across then down in RDLC report Pin
tantja22-Aug-08 3:53
tantja22-Aug-08 3:53 
QuestionScript (VBS) (WMI) To query Resultant Set of Policy (RSoP) and get security settings Pin
rocker198721-Aug-08 1:23
rocker198721-Aug-08 1:23 
Questioncannot invalidate() mdi child form from another Pin
Member 251239120-Aug-08 16:38
Member 251239120-Aug-08 16:38 
AnswerRe: cannot invalidate() mdi child form from another Pin
led mike21-Aug-08 5:12
led mike21-Aug-08 5:12 
QuestionWindows Forms + External Program Pin
raymondk20-Aug-08 11:17
raymondk20-Aug-08 11:17 
AnswerRe: Windows Forms + External Program Pin
AhsanS20-Aug-08 19:38
AhsanS20-Aug-08 19:38 
GeneralRe: Windows Forms + External Program Pin
raymondk20-Aug-08 20:06
raymondk20-Aug-08 20:06 
QuestionLoading controls with a BackgroundWorker Pin
james nugent20-Aug-08 7:05
james nugent20-Aug-08 7:05 
Hi,

I'm working with C# on .NET 3.5SP1. What I'm trying to achieve is as follows:

I have a form (frmShell) which can "spawn" other forms. Each of the other forms (frmMyFormType, for example), has a main content panel, into which I add a control of an appropriate type (cntMyFormTypeView, for example). Whilst the control is loading, I display a loading panel (cntLoader in my case).

In the constructor of each form I create a loading panel, and add it to the Controls of the content panel like this:

var Loader = new cntLoader { Dock = DockStyle.Fill };
contentPanel.Controls.Add(Loader);

In the Form_Load event, I then start a background worker, whose DoWork method looks something like this:

e.Result = Invoke(new CreateViewInvoker(CreateView), parameters.ObjectIdentifier);

Where CreateViewInvoker is defined with the following:

private delegate cntMyFormTypeView CreateViewInvoker(long itemId);

And the CreateView method is as follows:

private cntMyFormTypeView CreateView(long itemId)
{
return new cntMyFormTypeView(this, itemId) { Dock = DockStyle.Fill };
}

In the Completed method of the background worker, I do the following:

var control = (Control)e.Result;
contentPanel.Controls.Clear();
contentPanel.Controls.Add(control);
contentPanel.Invalidate();

The problem: this works, but freezes the UI when I Invoke the CreateView method (the constructor of cntMyFormTypeView can take a long time to run). This does make sense since it will be invoked on the UI thread.

Does anyone have any suggestions as to how to do this differently such that I create a control in the background (without locking up my UI), but then still use it from my UI thread?

Thanks,


James
AnswerRe: Loading controls with a BackgroundWorker Pin
Frank Horn20-Aug-08 7:18
Frank Horn20-Aug-08 7:18 
GeneralRe: Loading controls with a BackgroundWorker Pin
james nugent21-Aug-08 3:03
james nugent21-Aug-08 3:03 
GeneralRe: Loading controls with a BackgroundWorker Pin
Frank Horn21-Aug-08 4:59
Frank Horn21-Aug-08 4:59 
GeneralRe: Loading controls with a BackgroundWorker Pin
james nugent21-Aug-08 5:04
james nugent21-Aug-08 5:04 
GeneralRe: Loading controls with a BackgroundWorker Pin
Jon Hulatt22-Aug-08 3:47
Jon Hulatt22-Aug-08 3:47 
QuestionHow to Display the Value in the DataGridViewComboBox without having the Item [modified] Pin
Soma Shekhar19-Aug-08 8:04
Soma Shekhar19-Aug-08 8:04 
QuestionRe: How to Display the Value in the DataGridViewComboBox without having the Item Pin
Soma Shekhar20-Aug-08 8:01
Soma Shekhar20-Aug-08 8:01 
AnswerRe: How to Display the Value in the DataGridViewComboBox without having the Item Pin
led mike20-Aug-08 8:26
led mike20-Aug-08 8:26 
QuestionRe: How to Display the Value in the DataGridViewComboBox without having the Item Pin
Soma Shekhar21-Aug-08 1:19
Soma Shekhar21-Aug-08 1:19 
AnswerRe: How to Display the Value in the DataGridViewComboBox without having the Item Pin
led mike21-Aug-08 6:48
led mike21-Aug-08 6:48 
QuestionRe: How to Display the Value in the DataGridViewComboBox without having the Item Pin
Soma Shekhar21-Aug-08 17:20
Soma Shekhar21-Aug-08 17:20 
AnswerRe: How to Display the Value in the DataGridViewComboBox without having the Item Pin
led mike22-Aug-08 4:39
led mike22-Aug-08 4:39 
GeneralRe: How to Display the Value in the DataGridViewComboBox without having the Item Pin
Soma Shekhar27-Aug-08 8:44
Soma Shekhar27-Aug-08 8:44 
QuestionBest way to show PDF and Office documents in Windows Forms application? Pin
clackbee18-Aug-08 23:54
clackbee18-Aug-08 23:54 
AnswerRe: Best way to show PDF and Office documents in Windows Forms application? Pin
John_Adams19-Aug-08 9:36
John_Adams19-Aug-08 9:36 
QuestionTrackBar Pin
mcr.joe18-Aug-08 22:42
mcr.joe18-Aug-08 22:42 
AnswerRe: TrackBar Pin
Wendelius19-Aug-08 10:51
mentorWendelius19-Aug-08 10:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.