我正在尝试将此选项卡式浏览器从 Visual Basic 转换为 C++。我正在尝试从 Form1.h 中引用选项卡控件。这是 Form1.h 上的代码:
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
String^ title = String::Concat("TabPage ",(tabControl1->TabCount + 1).ToString());
tab^ newtab = gcnew tab;
newtab->Show();
newtab->TopLevel = false;
newtab->Dock = System::Windows::Forms::DockStyle::Fill;
TabPage^ myTabPage = gcnew TabPage(title);
myTabPage->Controls->Add(newtab);
tabControl1->TabPages->Add(myTabPage);
}
试图创建另一个选项卡的第二个表单上的代码是这样的:
private: System::Void newTabToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
tab^ newtab = gcnew tab;
newtab->Show();
newtab->TopLevel = false;
newtab->Dock = System::Windows::Forms::DockStyle::Fill;
TabPage^ myTabPage = gcnew TabPage();
myTabPage->Controls->Add(newtab);
tabControl1->TabPages->Add(myTabPage);
}
在 Visual Basic 中,只需添加 Form1。像这样开始......:
//Original
tabControl1.TabPages.Add(myTabPage);
//New
Form1.tabControl1.TabPages.Add(myTabPage);
我怎么能在 C++ 中做同样的事情?