2014年8月28日 星期四

[C#] Get Control in System.Windows.Forms

1.  Get Controls of certain type
var wbCollection = this.Controls.OfType<System.Windows.Forms.WebBrowser>().OrderBy(x=>x.Name);
wbCollection.ToList().ForEach(x => Debug.WriteLine(x.Name));
int wbCnt = wbCollection.Count();

int index =0;           (wbCollection.ToList())[index].Navigate(itemChecked.ToString());


2.  Get Controls of name
var wb = this.Controls.Find("wb1", true);
 ((wb.ToList())[0] as WebBrowser).Navigate("XXX");


沒有留言:

張貼留言