M
meh
I'm not sure if I have the right concept going. I am making a custom TabPage and executing it from a button click event. It works fine I'm just thinking I might be missing the finer points of the c# language. If not maybe I'm starting to catch on. Would like comments...better???...simpler???...
Here is the code....
tia
meh
// Build New Tab Page
//
string title = "tabPage" + (tabControl1.TabCount + 1).ToString();
TabPage myTabPage = new TabPage(title);
tabControl1.TabPages.Add(myTabPage);
//
// Build New tabPage with treeView1
//
TreeView CurrTree = new TreeView();
CurrTree.Dock = System.Windows.Forms.DockStyle.Fill;
CurrTree.ImageIndex = -1;
CurrTree.Indent = 19;
CurrTree.ItemHeight = 16;
CurrTree.Location = new System.Drawing.Point(0, 44);
CurrTree.Name = "CurrTree" + (tabControl1.TabCount).ToString();
CurrTree.SelectedImageIndex = -1;
CurrTree.Size = new System.Drawing.Size(292, 428);
CurrTree.TabIndex = 3;
// Adds new node as a child node of the currently selected node.
TreeNode newNode = new TreeNode();
newNode.Text = "Text for new node";
newNode.ImageIndex = 0;
newNode.SelectedImageIndex = 1;
CurrTree.Nodes.Add(newNode);
CurrTree.SelectedNode = newNode;
//
// Build New tabPage with myComboBox
//
ComboBox myComboBox = new ComboBox();
myComboBox.Dock = System.Windows.Forms.DockStyle.Top;
myComboBox.ItemHeight = 13;
myComboBox.Location = new System.Drawing.Point(0, 23);
myComboBox.Name = "comboBox" + (tabControl1.TabCount).ToString();
myComboBox.Size = new System.Drawing.Size(292, 21);
myComboBox.TabIndex = 2;
myComboBox.Text = "comboBox" + (tabControl1.TabCount).ToString();
//
myTabPage.Controls.Add(CurrTree);
myTabPage.Controls.Add(myComboBox);
//
// keep the toolbar
myTabPage.Controls.Add(tabToolBar);
//
//
tabControl1.SelectedTab = myTabPage;
myTabPage.Text = CurrTree.Name;
statusBar1.Panels[0].Text = myTabPage.Text;
// tabToolBar.BringToFront();
break;
Here is the code....
tia
meh
// Build New Tab Page
//
string title = "tabPage" + (tabControl1.TabCount + 1).ToString();
TabPage myTabPage = new TabPage(title);
tabControl1.TabPages.Add(myTabPage);
//
// Build New tabPage with treeView1
//
TreeView CurrTree = new TreeView();
CurrTree.Dock = System.Windows.Forms.DockStyle.Fill;
CurrTree.ImageIndex = -1;
CurrTree.Indent = 19;
CurrTree.ItemHeight = 16;
CurrTree.Location = new System.Drawing.Point(0, 44);
CurrTree.Name = "CurrTree" + (tabControl1.TabCount).ToString();
CurrTree.SelectedImageIndex = -1;
CurrTree.Size = new System.Drawing.Size(292, 428);
CurrTree.TabIndex = 3;
// Adds new node as a child node of the currently selected node.
TreeNode newNode = new TreeNode();
newNode.Text = "Text for new node";
newNode.ImageIndex = 0;
newNode.SelectedImageIndex = 1;
CurrTree.Nodes.Add(newNode);
CurrTree.SelectedNode = newNode;
//
// Build New tabPage with myComboBox
//
ComboBox myComboBox = new ComboBox();
myComboBox.Dock = System.Windows.Forms.DockStyle.Top;
myComboBox.ItemHeight = 13;
myComboBox.Location = new System.Drawing.Point(0, 23);
myComboBox.Name = "comboBox" + (tabControl1.TabCount).ToString();
myComboBox.Size = new System.Drawing.Size(292, 21);
myComboBox.TabIndex = 2;
myComboBox.Text = "comboBox" + (tabControl1.TabCount).ToString();
//
myTabPage.Controls.Add(CurrTree);
myTabPage.Controls.Add(myComboBox);
//
// keep the toolbar
myTabPage.Controls.Add(tabToolBar);
//
//
tabControl1.SelectedTab = myTabPage;
myTabPage.Text = CurrTree.Name;
statusBar1.Panels[0].Text = myTabPage.Text;
// tabToolBar.BringToFront();
break;