473,587 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting VScrollBar properties from within an OnPaint method

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
2 3929
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************* *@exisconsultin g.com

"Daisy" <da***@nospam.o ops> wrote in message
news:be******** **@linux01.dann ytuppeny.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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1128
by: Gawelek | last post by:
I would like to "cheat" VScrollBar in DataGrid. That means I want to link for example DataTable with 50 rows to DataGrid. But I want, that VScrollBar looks as if DataTable contains for example 100 or 1000 rows. Is it possible to do ? I tried by Maximum properties, but it seems not to work. Gawel
1
1268
by: Durand | last post by:
Hi all, I'm trying to create a vScrollBar with a dynamic value. When I change the maximum value inside a method, it works inside a method, but when I leave this method the maximum value returns to previous value. My vScrollBar is not declared inside any method. Thanks Durand
5
3075
by: Ron Vecchi | last post by:
I have a custyom control that has a property which wraps a collection. When I add controls to the collection the OnPaint method of these newly added controls never get fired. But if I take the controls in the collection and add them to the custom controls ControlCollection the OnPaint method is called. I would like to use my Collection property but It seems that the controls need to be added to the ControlCollection for them to work....
2
1977
by: Hans [DiaGraphIT] | last post by:
Hi! In a windowsapplication i have a datagrid where I dont want the vertical scrollbar to be visible. I can't find HorizontalScrollBar and VerticalScrollBar properties anywhere. I've tried to create controls for this... without luck. Here is the code I'm using. Please tell me what I'm doing wrong. this.InitializeScrollBar(DataGrid1)
0
1266
by: bleedledeep | last post by:
I have a DataGrid that ends up with a VScrollBar due to the number of rows, and the behavior I want is for the bottom-most row of the DataGrid to be shown, i.e., I want the VScrollBar all the way to the bottom (maximum). I grab and set the VScrollBar using the following: if ( historyDataGrid.Controls is VScrollBar ) { VScrollBar vsb = (VScrollBar)historyDataGrid.Controls;
3
5378
by: Tim | last post by:
Dear All, I have spend a number of hours attempting to find some answers about how to remove the 3D BorderStyle within a combobox and have come to the conclusion that the simplest method is to create a user control and hide the borders using some panels. This however is not the most efficient method of doing things so I appeal to those developers who know far more than I. I assume you need to create a derived class which inherits the...
7
2569
by: Peter Row | last post by:
Hi, I've started work on my own control some parts of which use standard controls, others I need to draw on my controls surface to get the display output I require, however.... I seem to be stupid or missing the point. I used DrawString( ) as a simple test but I cannot get it to work at all unless I handle my custom controls Paint event.
1
3603
by: sean | last post by:
I'm trying to create "rubber-band" rectangles by overriding the OnPaint method to place rectangles on top of all graphic controls, but when I call Me.Invalidate() (when the user moves the mouse), OnPaint is not getting called... Here is the relevent code: I'm trying to create a "rubber band" rectangle effect on my form. Private Sub HighlightSectionOfTrack(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles...
0
1092
by: Longkhi | last post by:
Hi everybody. I have quite a problem with the vscrollbar component. The control I'm using has a built-in scrollbar, but I have 5 of those controls, and I would like to bind the external vscrollbar to scroll them all synchronically. I have tried several other methods such as the wndProc override method. It didn't work, so I'm trying this alternative method.
0
7924
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8219
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.