Autoscroll problems on panal on a tabpage RRS feed

  • Question

  • I am totally perplexed by a problem I am having with using autoscroll in the compact environment - Put simply I want to add textboxes , labels etc progamatically to a panel that sits on a tabbed page.


    My code works fine on a PC - I set any newly added tabpages to autoscroll = true and then do the same for my panel and set autosize to true and add to the tab page -


    However, when you use the compact environment - there is no ability to set autosize to true.


    I figure I must be doing something silly somewhere as the initial state of the form has been set up using the drag and drop feature in visual studio. So tabpage one has a panel on it and works as expected. BUT when I set up an identical new tabpage with an  idetical new panel at run time - settings all the same as far as I can tell - the autoscroll does not work on the panel. The controls go onto the panel in the places desired - but no autoscroll.


    I can sort of fudge it by newpanel.Dock = doctstyle.bottom. But the scroll bars produced this way one up/down are not the same as on page one (two up/down left/right). And rather than the panel scrolling its the whole tabpage - not what I want at all but better than nothing. Which indicates to me that it is the tabpage not the panel that scrolls when docked.


    What do I have to do to make the panel scroll???


    I tried putting in an extra panel and then putting the panel into this and the docking the last panel into the first - but again it was the whole of the tabpage that autoscrolled not the panel.


    Anyone able to shed any light as why this is happening???

    Tuesday, September 11, 2007 2:50 PM


  • Hi captainpugwash ,

    Base on my understanding, you want to make the tabpage panel scroll at run time. If I have misunderstood you, please let me know, thanks.


    I have tried a sample like you mentioned, it works fine. you can try my code:



    Code Snippet

           private void frmTabpage_Load(object sender, EventArgs e)


                Label lb = new Label();          

                Label lb1 = new Label();

                Label lb2 = new Label();          

                Label lb3 = new Label();           

                Label lb4 = new Label();          

                Label lb5 = new Label();          

                Label lb6 = new Label();


                lb.Location = new System.Drawing.Point(3, 12);

                lb.Name = "label1";

                lb.Size = new System.Drawing.Size(100, 20);

                lb.Text = "dddddddddddddddd";


                // label2


                lb1.Location = new System.Drawing.Point(3, 43);

                lb1.Name = "label2";

                lb1.Size = new System.Drawing.Size(100, 20);

                lb1.Text = "eeeeeeeeeeeeeeeeee";


                // label3


                lb2.Location = new System.Drawing.Point(12, 78);

                lb2.Name = "label3";

                lb2.Size = new System.Drawing.Size(100, 20);

                lb2.Text = "ffffffffffffffffff";


                // label4


                lb3.Location = new System.Drawing.Point(12, 98);

                lb3.Name = "label4";

                lb3.Size = new System.Drawing.Size(100, 20);

                lb3.Text = "hhhhhhhhhhhhhhhhhhhhh";


                // label5


                lb4.Location = new System.Drawing.Point(12, 118);

                lb4.Name = "label5";

                lb4.Size = new System.Drawing.Size(100, 20);

                lb4.Text = "label1";



                Panel pan = new Panel();



                pan.AutoScroll = true;








                pan.Location = new System.Drawing.Point(7, 7);

                pan.Name = "pan";

                pan.Size = new System.Drawing.Size(226, 103);




    Best regards,

    Guang-Ming Bian - MSFT

    Friday, September 14, 2007 8:17 AM