开发者

initialise backgroundWoker in code

开发者 https://www.devze.com 2023-04-04 00:47 出处:网络
TextBox tb = Form1.thisForm.Controls[\"textbox1\"] as TextBox; how come i cant do the same with a backgroundWorker control?
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.

0

精彩评论

暂无评论...
验证码 换一张
取 消