locked
Opening new tab containing preset RRS feed

  • Question

  • Maybe not the right place but lets try :D

    First of all, This is my first ever real project, soo... I'm terrible at coding.. But you have to start somewhere right? :D

    So I'm using this command to open a new numberd tab each time I press the button, and now I wonder what I need to do to add a timer, a start/stop button for the timer, a "done" button that moves the tab to another tabcontroller and copy a already made checklist into the new tab, every time it is pushed :| :D

    Please help guys... I'm kinda stuck..

    private void button28_Click(object sender, EventArgs e) { string title = "" + (tabControl2.TabCount + 1).ToString(); TabPage myTabPage = new TabPage(title); tabControl2.TabPages.Add(myTabPage); }


    Tuesday, March 29, 2016 7:43 PM

Answers

  • Hi Casper Andvord,

    You could try the following code:

    Timer MainTimer = new Timer();
    
            bool IsMove = false;
    
            int oldPage = -1;
    
            private void Form1_Load(object sender, EventArgs e)
    
            {
    
                MainTimer.Interval = 1000;
    
                MainTimer.Tick += MainTimer_Tick;
    
            }
    
            private void btnTimer_Click(object sender, EventArgs e)
    
           {
    
                MainTimer.Enabled = !MainTimer.Enabled;
    
                btnTimer.Text = MainTimer.Enabled ? "Stop" : "Start";
    
            }
    
            private void btnMove_Click(object sender, EventArgs e)
    
            {
    
                IsMove = !IsMove;
    
                btnMove.Text = IsMove ? "Done" : "Move";
    
                if (IsMove)
    
                {
    
                    oldPage = tabControl1.SelectedIndex;
    
                }
    
                else
    
                {
    
                    MoveMethod(oldPage);
    
                }
    
            }
    
            private void MainTimer_Tick(object sender, EventArgs e)
    
            {
    
            }
    
            //move the control to select tabpage
    
            private void MoveMethod(int index)
    
            {
    
                if (index != -1)
    
                {
    
                    foreach (Control con in tabControl1.TabPages[index].Controls)
    
                    {
    
                        con.Parent = tabControl1.SelectedTab;
    
                    }
    
                    if (tabControl1.TabPages[index].Controls.Count > 0)
    
                        MoveMethod(index);
    
                }
    
            }
    

    Screenshots:

    Press Move,

    Choose a new TabPage,

    Press Done,

    Regards,

    Moonlight


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, March 30, 2016 5:42 AM

All replies

  • Hi Casper Andvord,

    It seems like your application is windows form, I moved your thread to the windows form forum for better support.

    Thanks for your understanding.

    Best Regards,

    Lake Xiao

    Wednesday, March 30, 2016 2:13 AM
  • Hi Casper Andvord,

    You could try the following code:

    Timer MainTimer = new Timer();
    
            bool IsMove = false;
    
            int oldPage = -1;
    
            private void Form1_Load(object sender, EventArgs e)
    
            {
    
                MainTimer.Interval = 1000;
    
                MainTimer.Tick += MainTimer_Tick;
    
            }
    
            private void btnTimer_Click(object sender, EventArgs e)
    
           {
    
                MainTimer.Enabled = !MainTimer.Enabled;
    
                btnTimer.Text = MainTimer.Enabled ? "Stop" : "Start";
    
            }
    
            private void btnMove_Click(object sender, EventArgs e)
    
            {
    
                IsMove = !IsMove;
    
                btnMove.Text = IsMove ? "Done" : "Move";
    
                if (IsMove)
    
                {
    
                    oldPage = tabControl1.SelectedIndex;
    
                }
    
                else
    
                {
    
                    MoveMethod(oldPage);
    
                }
    
            }
    
            private void MainTimer_Tick(object sender, EventArgs e)
    
            {
    
            }
    
            //move the control to select tabpage
    
            private void MoveMethod(int index)
    
            {
    
                if (index != -1)
    
                {
    
                    foreach (Control con in tabControl1.TabPages[index].Controls)
    
                    {
    
                        con.Parent = tabControl1.SelectedTab;
    
                    }
    
                    if (tabControl1.TabPages[index].Controls.Count > 0)
    
                        MoveMethod(index);
    
                }
    
            }
    

    Screenshots:

    Press Move,

    Choose a new TabPage,

    Press Done,

    Regards,

    Moonlight


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, March 30, 2016 5:42 AM