Advertisement

07.04.2008 at 10:31PM PDT, ID: 23540351
[x]
Attachment Details

how to deal with tabs in c# winforms

Asked by mathieu_cupryk in C# Programming Language, Microsoft Visual Basic.Net, Microsoft Visual C#.Net

I have four tabs in an application.
1) SelectPriceListTab
2) CreateUpdatePriceListTab
3) ErrorWarningsTab
4) CompareResultsTab
=============================================================================
Upon the loading of the application the SelectPriceListTab appears onlone as the first tab.
The other three are hidden.
=====================================================================
SelectPriceListTab:
Case 1: if user double clicks and selects a row on the the SelectPriceListTab Page then
add the 2 tab CreateUpdatePriceListTab.
Case 2: if user selects the create button on the SelectPriceListTab Page then add the 2 tab CreateUpdatePriceListTab.
=====================================================================
if the user clicks back to SelectPriceListTab then remove the  2 tab CreateUpdatePriceListTab.
if the user clicks on the Load Button of the CreateUpdatePriceListTab and errors occur then add
the 3rd tab ErrorWarningsTab and show results on that tab.
if the user clicks on the Compare button then add the 4th tab CompareResultsTab and display the page.
===========================================================================
if the user is in the error page tab and clicks the SelectPriceListTab  then remove the 2nd tab CreateUpdatePriceList.
Samething goes for if the user compare results page tab and clicks the SelectPriceListTab  then remove the 2nd tab CreateUpdatePriceList.
======================================================================
Now the user is in the SelectPriceListTab and there are perhaps the errorswarningtab and compareresultstab. this must before the errrorwarning or the compareresultstab.

 if user double clicks and selects a row on the the SelectPriceListTab Page then
add the 2 tab CreateUpdatePriceListTab
 if user selects the create button on the SelectPriceListTab Page then add the 2 tab CreateUpdatePriceListTab.

I need something to handle the above scenorios.
please see attached snippet.

       


 



      
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
this is what i have so far and needs cleanup.
#region "TabHandling"
        public void HandleTabs(TabPage tabName, int selectedTab, bool Add, bool Remove, bool OnLoad)
        {
            if (OnLoad) // First enter the application
            {
                lblMsg.Text = "Initialization successful.";
                this.MainTabControl.TabPages.Remove(CreateUpdatePriceListTab); // Update invisible until a row is selected or create button is clicked.
                this.MainTabControl.TabPages.Remove(ErrorWarningsTab);       // Error/Warning invisible until Load is completed.
                this.MainTabControl.TabPages.Remove(CompareResultsTab);      // Compare invisible until compare button is pressed. 
            }
 
            if (Add)
            {
                lblMsg.Text = "Add Tab.";
                this.MainTabControl.TabPages.Add(tabName);
               
                if (tabName == CreateUpdatePriceListTab)
                     this.MainTabControl.SelectTab(selectedTab);
                
                if (tabName == ErrorWarningsTab)
                     this.MainTabControl.SelectTab(selectedTab + 1);
                if (tabName == CompareResultsTab)
                     this.MainTabControl.SelectTab(selectedTab + 2);
 
                this.btnCreate.Visible = false;
            }
            if (Remove)
            {
                lblMsg.Text = "Remove Tab.";
                this.MainTabControl.TabPages.Remove(tabName);
                this.MainTabControl.SelectTab(selectedTab);
            }
 
          
        }
 
 
		private void TabsChanged()
		{
            switch (MainTabControl.SelectedIndex)
            {
                case 0:
                    {
                        this.MainTabControl.TabPages.Remove(CreateUpdatePriceListTab); // Update invisible until a row is selected or create button is clicked.
                        this.btnCreate.Visible = true;
                        lblMsg.Text = "Create/Update a new price list.";
                        break;
                    }
 
                //    case 1:
                //         {
                //             this.btnCreate.Visible = false;
                //             this.btnLoad.Enabled = false;
                //             break;
                //         }
 
            }
            lblMsg.Text = "";
		} 
 
		private void MainTabControl_SelectedIndexChanged(object sender, EventArgs e)
		{
     
            switch (MainTabControl.SelectedIndex)
            {
                case 0: // means we have a select tab
                {
                    lblMsg.Text = "";
                    HandleTabs(CreateUpdatePriceListTab, MainTabControl.SelectedIndex, false, true, false);
                    btnCreate.Visible = true;
                    break;
                }
 
              case 1:
              {
                    lblMsg.Text = "";
                    this.btnCreate.Visible = false;
                    this.btnLoad.Enabled = false;
                    break;
               }
		   
              }
 
 
          }
 
        #endregion
[+][-]07.07.2008 at 02:15AM PDT, ID: 21943540

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, Microsoft Visual Basic.Net, Microsoft Visual C#.Net
Sign Up Now!
Solution Provided By: dungla
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.07.2008 at 07:44AM PDT, ID: 21945470

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.07.2008 at 08:23AM PDT, ID: 21945869

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.08.2008 at 06:16PM PDT, ID: 21959840

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628