473,386 Members | 1,795 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,386 software developers and data experts.

Clip a child control

Hi, I created a control deriving from System.Windows.Forms.Control. In
my own OnPaint method, I can draw and set the clipping and everything
is perfect. But I also added some checkboxes by setting their parent
as my control, and I can seem to get them to clip. They just draw
themselves over anything that's under them, right up to the very edge
of the control. How do I get them to clip where I want? Do I set a
property in my control, set one of their properties, a property of the
Graphics object? I'm really confused here...

I'd appreciate any help or insight...

Thanks,
-Brad

Nov 17 '05 #1
3 2724
You should be able to use the "Region" property for this purpose.
http://msdn.microsoft.com/library/de...egiontopic.asp

--
Tim Wilson
..Net Compact Framework MVP

"BradBrigade" <si********@hotmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Hi, I created a control deriving from System.Windows.Forms.Control. In
my own OnPaint method, I can draw and set the clipping and everything
is perfect. But I also added some checkboxes by setting their parent
as my control, and I can seem to get them to clip. They just draw
themselves over anything that's under them, right up to the very edge
of the control. How do I get them to clip where I want? Do I set a
property in my control, set one of their properties, a property of the
Graphics object? I'm really confused here...

I'd appreciate any help or insight...

Thanks,
-Brad

Nov 17 '05 #2
Well, that seems to work globally, for the whole control, but I need to
be able to set different regions on different parts of the control. I
have scroll bars and if I reduce the region to where I want the
checkboxes confined, the scrollbars wont draw because they'll be
outside the region. I think the problem is I can draw my own graphics
fine, but as soon as OnPaint exits, all the scrollbars and checkboxes
draw and I don't have control over their clipping except globally with
Region. Is there a way to tell the child controls when to draw? Then
I could set the region, tell the checkboxes to draw, then increase the
region and tell the scrollbars to draw, then draw my own stuff. Is
that possible? What is the usual way to handle this situation?

Thanks,
-Brad

Tim Wilson UNDERSCORE AT PERIOD wrote:
You should be able to use the "Region" property for this purpose.
http://msdn.microsoft.com/library/de...egiontopic.asp

--
Tim Wilson
.Net Compact Framework MVP


Nov 17 '05 #3
If you know the scrollbars are going to be there then you can take the
scrollbars into consideration when you paint, or size the child controls, by
using the "HorizontalScrollBarHeight" and "VerticalScrollBarWidth"
properties of the "SystemInformation" class.
http://msdn.microsoft.com/library/de...mberstopic.asp

You can assign a different region to each child control if that makes things
easier. If you need a complex region then you can create a "GraphicsPath"
object and then pass this object to one of the constructor overloads for the
"Region" class to create a region using the GraphicsPath.
http://msdn.microsoft.com/library/de...classtopic.asp

I think that you may need to use one of these techniques, or a combination
of both, to achieve what you're trying to do.

--
Tim Wilson
..Net Compact Framework MVP

"BradBrigade" <si********@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Well, that seems to work globally, for the whole control, but I need to
be able to set different regions on different parts of the control. I
have scroll bars and if I reduce the region to where I want the
checkboxes confined, the scrollbars wont draw because they'll be
outside the region. I think the problem is I can draw my own graphics
fine, but as soon as OnPaint exits, all the scrollbars and checkboxes
draw and I don't have control over their clipping except globally with
Region. Is there a way to tell the child controls when to draw? Then
I could set the region, tell the checkboxes to draw, then increase the
region and tell the scrollbars to draw, then draw my own stuff. Is
that possible? What is the usual way to handle this situation?

Thanks,
-Brad

Tim Wilson UNDERSCORE AT PERIOD wrote:
You should be able to use the "Region" property for this purpose.
http://msdn.microsoft.com/library/de...egiontopic.asp
--
Tim Wilson
.Net Compact Framework MVP

Nov 17 '05 #4

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

Similar topics

3
by: red | last post by:
mouse events when the mouse is on a "child control" hi everyone; my problem: I have a userControl in this usercontrol, I have a child control (a button) when the mouse moves over the...
1
by: h | last post by:
I have a custom control that consist of one or more custom child controls (I made a custom List control, where each list item is a group of a text and button controls). When I resize one "child"...
2
by: Dave Veeneman | last post by:
Is there a simple way to pass drag-and-drop events to a child control in a UserControl? Here's an example: I have created a UserControl which contains a treeview and some text boxes. I want to...
2
by: Harry | last post by:
Hello, I have a composite WebControl that I'm dynamically instantiating at runtime using Reflection. When I create a new instance of my control I immediately iterate through it's child control...
0
by: Qwert | last post by:
Heya, I have a user control (inherits from listview control). I add a textbox control to it as a child control and give the child control the focus. All is well when I type text (keyboard input)...
2
by: isacc manit | last post by:
How to access child control from a panel Control or (LoginView etc..) in code For example Changing text from a lable that is in a panel Control -- VB.NET
3
by: Jon Paal | last post by:
i have a textbox control inside a custom server control that needs to be prefilled with content. how do i find this child control ? <ew:cp id="ccp2" TitleText="" runat="server">...
0
by: --== Alain ==-- | last post by:
Hi, I have a control (let's called it : Container) which include several "Child" controls. 1. I would like to detect if a child control is out of the display rectangle of the container. If...
8
by: svibuk | last post by:
i have a div element with a child control in it which gets populated with data depending on data teh control expands and also the div. if i set the div width the data overflows in the extended...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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?
0
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
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.