• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

C# Windows Form

Is there a way to create a control that has tabs that appear to extend beyond the boundaries of the control?
0
tsmolskow
Asked:
tsmolskow
1 Solution
 
AlexFMCommented:
What about using TabControl?
0
 
madprCommented:
Try placing a Panel container on the form with AutoScroll set to true - this will give you scrollbars if a child extends
beyond the size of the panel. Next add a child TabPanel to it and set whatever with and height you need it to be.
0
 
shtsonCommented:
What you should actually do
is make ur comtrol bigger
and override the OnPaint method
and paint the tabs urself
that way - you can get transparency on the top of the control (where it collides with the background form)
and you can turn it on / off by simply not painting anything there.

Cheers,
Shai
0
 
tsmolskowAuthor Commented:
Sounds cool, can you give me a code example for the override on Paint method?
0
 
shtsonCommented:
Ok, but its a very simple

A. Create a new windows form project
B. Add a UserControl file
C. Add a button to the user control
D. Add the following code to the user control:
            protected override void OnPaint(PaintEventArgs e)
            {
                  base.OnPaint (e);

                  if( m_DrawBox )
                  {
                        using( Brush fill = new SolidBrush(Color.Gray) )
                        {
                              e.Graphics.FillRectangle(fill, 5, 5, 100, 100);
                        }

                        using( Pen border = new Pen(Color.Black) )
                        {
                              e.Graphics.DrawRectangle( border, 5, 5, 100, 100 );
                        }
                  }
            }

            private void button1_Click(object sender, System.EventArgs e)
            {
                  m_DrawBox = !m_DrawBox;
                  this.Invalidate( true );
            }
E. Set the buttons Click event to point to the function
F. Build the project
G. Add the control to your form
H. Run!

Have fun
Cheers,
Shai
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now