Control c = Controls.Find(New,true)[0]; //najiti komponenty if (c == null) {}
但它给了我错误,索引超出了数组的范围.我知道这段代码很糟糕,但我不知道写得好,谷歌也不帮我.
Find
Control[] controls = Controls.Find(New,true); if (controls.Length > 0) { //logic goes here } else { //no components where found }