By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,498 Members | 1,783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,498 IT Pros & Developers. It's quick & easy.

Getting VScrollBar properties from within an OnPaint method

P: n/a
I've got a custom control that works fine, it's DockStyle is set to Fill for
the panel it's in.

I've just added a VScrollBar docked Right in the panel. It appears, and
works fine, however in the OnPaint method of my custom control, I need to
know where the scrollbar is, so I can paint the relevant part of my control.

Since the ScrollBar exists in my MainForm, and the customcontrol is a class
of it's own, I can't figure out how to get at it. I was looking at the
Container property on each control, trying to get back to the MainForm,
which I could then get at it from, but apart from not working, that also
only seems to work if you know the index for the control in it's container,
and not if you know the name.

How should I achieve this?

--
Daisy The Cow
Now playing: Justin Timberlake ft 50 Cent - Rock Your Body In Da Club
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Daisy,

This design is flawed. If you want your control to know where the
scrollbar is, then the form should pass the scrollbar to the control in some
manner so that it can do what it needs to do with it. Either that, or the
control itself should be responsible for displaying the scrollbars, so that
it would know where they are.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Daisy" <da***@nospam.oops> wrote in message
news:be**********@linux01.dannytuppeny.com...
I've got a custom control that works fine, it's DockStyle is set to Fill for the panel it's in.

I've just added a VScrollBar docked Right in the panel. It appears, and
works fine, however in the OnPaint method of my custom control, I need to
know where the scrollbar is, so I can paint the relevant part of my control.
Since the ScrollBar exists in my MainForm, and the customcontrol is a class of it's own, I can't figure out how to get at it. I was looking at the
Container property on each control, trying to get back to the MainForm,
which I could then get at it from, but apart from not working, that also
only seems to work if you know the index for the control in it's container, and not if you know the name.

How should I achieve this?

--
Daisy The Cow
Now playing: Justin Timberlake ft 50 Cent - Rock Your Body In Da Club

Nov 13 '05 #2

P: n/a
> This design is flawed. If you want your control to know where the
scrollbar is, then the form should pass the scrollbar to the control in some manner so that it can do what it needs to do with it. Either that, or the
control itself should be responsible for displaying the scrollbars, so that it would know where they are.


I thought so!

I'll try attaching scrollbars inside my control. It's DockStyle is set to
Fill, I assume I can just dock scrollbars to the right/bottom from inside my
control?
--
Daisy The Cow
Now playing: Nothing
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.