문제

From the original form form1, I can call this easily

this.tabControl1.SelectedTab.Text

But from form2, I cannot find equivalent method

(form1.Controls["tableLayoutPanel1"].Controls["tabControl1"] as TabControl) 

does not have the SelectedTab method

도움이 되었습니까?

해결책

Make the modifier on the TabControl's field Public, then you will be able to reference the tab control directly via the field with a reference to Form2.

It will look something like this after you have made the field public.

Form1 frm1 = <A reference to Form1 that you passed in to Form2 somehow>
frm1.TabControl1.SelectedTab.Text = "Changed Text!";
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top