473,480 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do you draw a border around a scrollable control

I have a scrollable control I'm working on.
Some parts of the painting I want to always be in the same position
like my border. But when I hit the scroll bars my border moves. I
dont't understand why. Here's an example:

public class ListTable : System.Windows.Forms.ScrollableControl
{
public ListTable()
{
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);

AutoScrollMinSize = new Size( 300, 300 );
}

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

//Draw Border
e.Graphics.DrawRectangle(Pens.Gray, 0,0, DisplayRectangle.Width-1,
DisplayRectangle.Height-1);
}
}

I thought this would keep the border in the same place since I am not
doing and translating and because the width/height of DisplayRectangle
never change.
But when I click on the scroll buttons my border moves around.
Why is this? What should I do? I do want some parts to scroll, just
not everything.
Jul 21 '05 #1
0 1444

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

Similar topics

0
1923
by: Florida Draw | last post by:
------=_NextPart_000_0012_1D5428A2.65C196F8 Content-Type: text/plain Content-Transfer-Encoding: 8bit Sign-up for the FREE Holiday Giveaway Draw You must register to be eligible for the draw....
6
3310
by: Rolf Brauser | last post by:
Hello, is it possible to draw a one pixel line around every cell in a table? with "border: 1px solid; " just the outer tableborder ist concerned ? thanks for any help rolf
1
2581
by: Patrick Blackman | last post by:
I would like to have a panel control which has the ability to have different color borders, any idea how to accomplish this. Thanks
0
1797
by: John R. | last post by:
I want to add a textbox next to each item in a Listbox on a Windows Form. The items need to be scrollable so I thought that maybe this is possible with an Owner Draw listbox. Searching the web...
3
4214
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
0
315
by: Phill | last post by:
I have a scrollable control I'm working on. Some parts of the painting I want to always be in the same position like my border. But when I hit the scroll bars my border moves. I dont't understand...
7
10676
by: Mark Ingram | last post by:
Hi, how can i draw a rounded rectange, with a border within a specified area? i.e. if i have a Rectangle with width and height of 100, how can i draw a rectange with 2 pixel border inside of the...
8
12080
by: UJ | last post by:
I have a table with multiple cells and I want to draw a box around the entire table but not around the individual cells. How do I do that? TIA - Jeff.
8
2175
by: Mel | last post by:
I need to draw a red frame around the element under current pointer. I have seen it done in debuggers, but need to have it in my application, without the need to download and install...
0
7048
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,...
0
6911
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...
0
7050
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,...
1
4787
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...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2999
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...
0
2988
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
185
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...

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.