Skip to content

To center TabPage Scroll Bar

fatih simsek

Asked Jul 27, 2007, 11:59 PM EDT1 answer
Share
LinkedInX
I have a tabpage and a panel inside this tabpage. When I insert anything to panel I want to center tabpage's scrollbar because I insert anything center of this tabpage but TabPage Scrollbar place on left.Can you explain that how I code that???

how can I reach height of scrollbar(tabpage's autoscroll)????

http://www.resimupload.com/ds794669779_prog.html

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Java
    TabPage page = new TabPage( );
    page.AutoScroll = true;
    
    Button btn = new Button( );
    btn.Text = "Add label";
    btn.Click += delegate
    {
    Label lbl = new Label( );
    lbl.Location = new Point( 0, 100 );
    lbl.Anchor = AnchorStyles.Left;
    lbl.AutoSize = false;
    lbl.Width = this.Width + 400;
    lbl.BackColor = Color.Red;
    lbl.TextAlign = ContentAlignment.MiddleCenter;
    lbl.Text = "centered text";
    page.Controls.Add( lbl );
    if ( lbl.Width > page.Width )
    {
    page.AutoScroll = false;
    page.HorizontalScroll.Value = ( page.HorizontalScroll.Maximum - page.HorizontalScroll.LargeChange ) / 2;
    page.AutoScroll = true;
    }
    btn.Dispose( );
    };
    TabControl tabCtrl = new TabControl( );
    tabCtrl.Dock = DockStyle.Fill;
    tabCtrl.TabPages.Add( page );
    this.Controls.Add( btn );
    this.Controls.Add( tabCtrl );
    0