//Adding a new accessory item //Adds a new tab to our accessory tab control private void AddNewAccessory(object sender, System.EventArgs e) { TabPage tempTab = tabControl1.SelectedTab; //If we haven't clicked the "Add+" tab, don't go any further in the code and return if (tempTab != tabControl1.TabPages["addTab"]) { return; } //Change Tab Text, then change its Name identifier, then increment the tabNum variable by 1 ChangeTabText(tempTab, "New Acc"); tempTab.Name = tabNum.ToString(); tabNum++; //Now we create the new tab that will be "Add+" AccTab newPage = new AccTab(); newPage.ThePage.Name = "addTab"; //Have to set the name so we can alter this tab later if it's clicked on newPage.tabNum = tabNum; newPage.DisplayLabelNames(); newPage.DisplayInputBoxes(tabControl1, pNameList, processList); newPage.nameBox.LostFocus += new EventHandler(UpdateWOList); newPage.numBox.LostFocus += new EventHandler(UpdateWOList); newPage.serialBox.LostFocus += new EventHandler(UpdateWOList); newPage.processBox.LostFocus += new EventHandler(UpdateWOList); newPage.remarksBox.LostFocus += new EventHandler(UpdateWOList); tabControl1.TabPages.Add(newPage.ThePage); acc_list.Add(new Accessory()); //Need to find a way to show the acc_list values on screen for debugging and testing purposes }
private int tabNum; //New name of our "Add+" tab, when we select it. Increments public Form1() { //Initialize our variables acc_list = new List <Accessory>(); tabNum = 0; //Initialize and fill up our pNameList and processList variables pNameList = new List <string>(); pNameList.Add("Magneto"); pNameList.Add("Fuel Pump"); pNameList.Add("Fuel Servo"); pNameList.Add("Manifold Valve"); pNameList.Add("Flow Divider"); pNameList.Add("Starter Adapter"); processList = new List <string>(); processList.Add("O/H"); processList.Add("500 Hour"); processList.Add("IRAN"); InitializeComponent(); //Initialize our first "Add+" tab AccTab secondTab = new AccTab(); secondTab.ThePage.Name = "addTab"; //Have to set the name so we can alter this tab later if it's clicked on secondTab.DisplayLabelNames(); secondTab.DisplayInputBoxes(tabControl1, pNameList, processList); secondTab.nameBox.LostFocus += new EventHandler(UpdateWOList); secondTab.numBox.LostFocus += new EventHandler(UpdateWOList); secondTab.serialBox.LostFocus += new EventHandler(UpdateWOList); secondTab.processBox.LostFocus += new EventHandler(UpdateWOList); secondTab.remarksBox.LostFocus += new EventHandler(UpdateWOList); tabControl1.TabPages.Add(secondTab.ThePage); }