473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Can't get scrollbars to show up

I'm doing some custom drawing to a Panel object overriding the onPaint, and
the stuff I draw usually goes beyond the ClipRectangle of the panel's current
size- so I set autoscroll to true yet it never shows scrollbars. I also tried
putting my custom Panel inside of a regular Panel with Autoscroll true andf
it still does not work.

What can I do to make scrollbars appear? Is there a size setting I have to
change on my Panel so that it knows I drew beyond the ClipRectangle?
Nov 17 '05 #1
5 4928
MrNobody,

The documentation for the ScrollableControl class states:

To manually override which scroll bars are visible, set the VScroll and
HScroll properties. If either property is set to false, the corresponding
scroll bar is not visible, even if the AutoScroll property is set to true.

Have you set these manually? Since you are painting the control
yourself, it doesn't know if you have to scroll the contents or not.

What you might want to do is host a panel control in your control which
has a docking of fill. Then, when you have to redraw the panel, you resize
your inner pannel to the appropriate size. When you do that, the parent
control should show or hide the scrollbars appropriately.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"MrNobody" <Mr******@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
I'm doing some custom drawing to a Panel object overriding the onPaint,
and
the stuff I draw usually goes beyond the ClipRectangle of the panel's
current
size- so I set autoscroll to true yet it never shows scrollbars. I also
tried
putting my custom Panel inside of a regular Panel with Autoscroll true
andf
it still does not work.

What can I do to make scrollbars appear? Is there a size setting I have to
change on my Panel so that it knows I drew beyond the ClipRectangle?

Nov 17 '05 #2
Nicholas, Thank you for the reply!

I tried that VScroll property and it didn't seem to have an effect, either
with Autoscroll on or off.

I'm not quite sure what you mean by having an inner panel, when I add a
panel to my custom panel then it overwrites whatever I draw with blank space.

Here's a simplified version of my problem:

public class MyPanel : Panel {

public MyPanel () : base () {
this.VScroll = true;
this.AutoScroll = true;
}

protected override void OnPaint(PaintEventArgs e) {
base.OnPaint (e);

Pen p = new Pen(Brushes.Blue, 2);
e.Graphics.DrawLine(p, 50, 0, 50, 250);
}

}

And then on the main form do this:

MyPanel panel = new MyPanel();
panel.Size = new Size(100, 150);
panel.Location = new Point(50,50);
panel.BorderStyle = BorderStyle.FixedSingle;
panel.BackColor = Color.White;
this.Controls.Add(panel);

So the main panel gives it a size smaller than what it draws (the line
extends beyond the bottom clip boundary). Nothing I do seems to get
scrollbars to show up
Nov 17 '05 #3
MrNobody,

Create a custom control which derives from Panel. Then, in the
constructor, create an inner pannel control which is a child of your custom
control. The inner pannel control will be placed at 0, 0 in the parent
control. Then, the inner pannel will be the panel that paints itself, and
sizes itself according to what you have to paint. When you resize the inner
panel, it will cause the scrollbars to appear or disappear according to the
size of the inner pannel.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"MrNobody" <Mr******@discussions.microsoft.com> wrote in message
news:AB**********************************@microsof t.com...
Nicholas, Thank you for the reply!

I tried that VScroll property and it didn't seem to have an effect, either
with Autoscroll on or off.

I'm not quite sure what you mean by having an inner panel, when I add a
panel to my custom panel then it overwrites whatever I draw with blank
space.

Here's a simplified version of my problem:

public class MyPanel : Panel {

public MyPanel () : base () {
this.VScroll = true;
this.AutoScroll = true;
}

protected override void OnPaint(PaintEventArgs e) {
base.OnPaint (e);

Pen p = new Pen(Brushes.Blue, 2);
e.Graphics.DrawLine(p, 50, 0, 50, 250);
}

}

And then on the main form do this:

MyPanel panel = new MyPanel();
panel.Size = new Size(100, 150);
panel.Location = new Point(50,50);
panel.BorderStyle = BorderStyle.FixedSingle;
panel.BackColor = Color.White;
this.Controls.Add(panel);

So the main panel gives it a size smaller than what it draws (the line
extends beyond the bottom clip boundary). Nothing I do seems to get
scrollbars to show up

Nov 17 '05 #4
I must be misunderstanding something because I cannot seem to get the
behavior you describe doing the steps you listed. Create a custom control
which does it's own drawing but in it's consutructor create another instance
of itself? Would you be able to show me what you mean via pseudo code or just
regular code?
Nov 17 '05 #5
MrNobody,

You have a custom control derived from Panel. You add another Panel
(not your custom control) in the constructor, and paint in that. Something
like this:

public class MyPanel : Panel
{
// The internal panel that is drawn on.
private Panel drawingPanel;

public Panel()
{
// Set the auto scroll property to true.
this.AutoScroll = true;

// Create the panel.
drawingPanel = new Panel();

// Add it.
this.Controls.Add(drawingPanel);

// Set the location of the panel to the origin, so that it looks
like painting on the panel takes place on the
// control.
drawingPanel.Location = new Point(0, 0);

// Set the size of the inner panel here.
// You can also set the size anywhere else that you wish. When you
adjust the size of the
// drawing panel, this control should show the scrollbars if the
size of the inner panel exceeds the size of
// this control. You might also have to set the Dock property of
the drawingPanel to the top left corner.
drawingPanel.Size = ...
}

private void DrawingPanelPaintEventHandler(object sender,
PaintEventArgs)
{
// Handle the painting here.
}
}
"MrNobody" <Mr******@discussions.microsoft.com> wrote in message
news:58**********************************@microsof t.com...
I must be misunderstanding something because I cannot seem to get the
behavior you describe doing the steps you listed. Create a custom control
which does it's own drawing but in it's consutructor create another
instance
of itself? Would you be able to show me what you mean via pseudo code or
just
regular code?

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Donius | last post by:
Hello! I've been headhunting for a javascript popup that i saw once, that when it's called, pops open and grows from the center to its desired h and w. Does anyone have any idea where i could...
8
by: Andrew Phillipo | last post by:
I have a layout which works perfectly. It is three column, the central column is width:auto; with margins and the columns are absolutely positioned at top:0px; left:0px; and top:0px;right:0px; ...
1
by: Andi Plotsky | last post by:
I have a subform where I dynamically change the SourceObject dependent upon the User's response to questions on the Main form. My problem is that the scrollbars do not show up on either the Main...
4
by: scorpion53061 | last post by:
I have a datagrid that is switches between 2 different datasources. I set the anchor properties of my datagrid to for bottom, top, left , right. My form is set ot maximize on open. If the...
0
by: Tom | last post by:
I have a panel that is set for autoscrolling, however I -DON'T- want the scrollbars to show up. Do anyone know of any way to make a panel autoscroll and yet have no scrollbars? I know that is an...
0
by: Tor Inge Rislaa | last post by:
How to control the scrollbars in datagrid In VB 6.0 you could control if you wanted the scrollbars to be automatic on when needed or if you just wanted to show vertical or horizontal scrollbar....
2
by: Ernst Elzas | last post by:
Hello, If these questions have been asked numerous times before, please excuse me, I have not managed to find the information I needed. I'm making a webpage (for now it will only be in two...
0
WebMissy
by: WebMissy | last post by:
I have a forum all set up and everything works great. I decide to use IE 7 for the benefit of transparent PNG files. All is well with that but now my scripting for my colored scrollbars doesn't...
1
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
Hi, Is there a way to detect whenever scrollbars (the vertical) are shown on a treeview I need to know. 1) If scrollbars are visible after a rezise 2) If scrollbars are visible after change...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.