1
的控件創建具有RichtTextBox新MDIChild:獲取MDIChild
Form myForm = new Form();
myForm.MdiParent = this;
RichTextBox rtb = new RichTextBox();
myForm.Controls.Add(rtb);
myForm.Show();
由於可能存在於它打開沒有RTB其他一些MDIChilds,我要檢查,如果ActiveChild中有一個RichtTextBox。我不知道如何在一個try-catch做到這一點... 是這樣的(?):
foreach (Control control in this.ActiveMdiChild.Controls)
{
// check if the control is a checkbox
// make the richttextbox as an object so I can do strange things with it ^^
}
能否請你幫我嗎?
THX &乾杯 亞歷
謝謝約翰,這對我很有用! – DaFunkyAlex 2013-03-20 14:46:20
不客氣! – 2013-03-20 14:47:19
'if(control.GetType()== typeof(System.Windows.Forms.RichTextBox)'與'if(control是RichTextBox)'是一樣的,因爲我發現了^^ – DaFunkyAlex 2013-03-20 14:57:43