473,625 Members | 3,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2745
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

"BradBrigad e" <si********@hot mail.com> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.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 "HorizontalScro llBarHeight" and "VerticalScroll BarWidth"
properties of the "SystemInformat ion" 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 "GraphicsPa th"
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

"BradBrigad e" <si********@hot mail.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.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
10589
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 userControl, I can detect the movement using MouseMove event. the problem is when the mouse is on the child control : I can t detect
1
2604
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" control item, I would like the "Parent" control to adjust the positions of other "child" controls. Therefore I'd like the event that resizes the "child" control to trigger "parent" control's function to adjust positions (e.g. AdjustPositions() )
2
7115
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 be able to drag-and-drop to the treeview from outside the UserControl. Now, when I drag over the treeview in the UserControl, the UserControl gets the drag-and-drop events, but the treeview doesn't. Is there a simple way to pass drag-and-drop...
2
1846
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 collection (it has about 4 child controls). The problem is none of these controls are loaded or accessible when I create the instance since, I believe, they are created by the server at a later point in time. How could I force my composite control...
0
1304
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) but when I click on the child control for the first time, the click event of the parent control is triggered and the parent control gets the focus. When I click again on the child control, the child control's event is triggered and it gets the...
2
1041
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
1527
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"> <asp:TextBox id=TB1" runat="server" /> </ew:cp>
0
1203
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 yes, i would like to know if it is horizontally or vertically. Based on that, i would like to display the appropriate scrollbar (horizontal and/or vertical)
8
5495
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 control i need to use clip property i tried setting it but i am not getting teh result clip:rect(0 30 30 0); how do i set the parent and child element
0
8694
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
8635
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
7184
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...
0
5570
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
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
4193
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1500
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.