initialise backgroundWoker in code
TextBox tb = Form1.thisForm.Controls["textbox1"] as TextBox;
how come i cant do the same with a backgroundWorker control?
开发者_JS百科backgroundWorker wk = Form1.thisForm.Controls["backgroundWorker1"] as backgroundWorker;
Because BackgroundWorker is not Control and doesn't belong to Controls collection.
Windows Form designer generates C# code which creates backgroundWorker1 instance. You can use it directly. But this instance is not added (and cannot be added) to the Form Controls property.
精彩评论