//ADDING A NEW WEEK TO TABS private void btnAddWeek_Click_1(object sender, EventArgs e) { // create a new TabPage TabPage newTP = new TabPage(); //Add it to the TabControl tabControl1.TabPages.Add(newTP); // Set the title (here "Week" plus the tab page number: 1 ,2 ,3, etc) int TabPageNumber = tabControl1.SelectedIndex + 1; // +1 one up from current tabControl1.TabPages[TabPageNumber].Text = "Week " + (TabPageNumber + 1); // Make it active (bring to the front of all other tab pages) tabControl1.SelectTab(TabPageNumber); btnDeleteWeek.Enabled = true; // We now have something to delete // Make the new tab page the parent of the Panel that hold all the controls panel1.Parent = tabControl1.SelectedTab; // Comment this line out to see effect // update your data structure with default values ShowData(); } //CHANGING BETWEEN TABS private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { { panel1.Parent = tabControl1.SelectedTab; TabPage selectedTab = tabControl1.SelectedTab; int selectedIndex = tabControl1.SelectedIndex; tabControl1.SelectedTab = selectedTab; // Over to you: Update the controls in the panel from the // data structure to show the correct content } } //DELETING A WEEK FROM THE TABS private void btnDeleteWeek_Click(object sender, EventArgs e) { // Removes the currently active TabPage. tabControl1.TabPages.Remove(tabControl1.SelectedTab); // Disable button if only one TabPage left. Otherwise crash! if (tabControl1.SelectedIndex < 1) btnDeleteWeek.Enabled = false; // Over to you: delete the data in your data structure } //CHANGING THE INSTOCK VALUE IN THE COUNTER private void numericUpDown2_ValueChanged(object sender, EventArgs e) { // 1. create a new structure that can hold results for 5 weeks myStruct aNewStruct = new myStruct(5); // 2. copy the content of the current ArrayList data structure // into the new structure aNewStruct = (myStruct)dataList[currentEntryShown]; try { aNewStruct.instock[0] = Convert.ToInt32(numericUpDown2.Value); } catch { aNewStruct.instock[0] = 0; } // 3. update the data structure to what the GUI shows aNewStruct.instock[tabControl1.SelectedIndex] = (int)numericUpDown2.Value; // 4. overwrite the old data with the changed one. dataList[currentEntryShown] = aNewStruct; } private void numericUpDown1_ValueChanged(object sender, EventArgs e) { // 1. create a new structure that can hold results for 5 matches myStruct aNewStruct = new myStruct(5); // 2. copy the content of the current ArrayList data structure // into the new structure aNewStruct = (myStruct)dataList[currentEntryShown]; try { aNewStruct.sold[0] = Convert.ToInt32(numericUpDown1.Value); } catch { aNewStruct.sold[0] = 0; } // 3. update the data structure to what the GUI shows aNewStruct.sold[tabControl1.SelectedIndex] = (int)numericUpDown1.Value; // 4. overwrite the old data with the changed one. dataList[currentEntryShown] = aNewStruct; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)