473,325 Members | 2,828 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,325 software developers and data experts.

Custom Rounded Rectangle Usercontrol does not redraw controls on it. Please help.

I made a custom runded rectangle usercontrol. I used a function i found on
the internet. the function works fine(see "GetRoundRect" below).
I use the fullowing code to make my usercontrol rounded....
************************************************** ***
Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
Dim x1 As Integer = 0
Dim x2 As Integer = Me.ClientSize.Width
Dim iHeight As Int32 = Me.Height
Dim iWidth As Int32 = Me.Width
If bCurveSided Then
Dim eg As New ExtendedGraphics(e.Graphics)
Dim rf As New RectangleF()
With rf
.Width = iWidth
.Height = iHeight
.X = 1
.Y = 0
End With
Me.Region = New Region(eg.GetRoundedRect(rf, 5))
End If
End Sub

Public Function GetRoundedRect(ByVal baseRect As RectangleF, ByVal
radius As Single) As GraphicsPath
If radius <= 0 Then
Dim mPath As GraphicsPath = New GraphicsPath()
mPath.AddRectangle(baseRect)
mPath.CloseFigure()
Return mPath
End If
If radius >= (Math.Min(baseRect.Width, baseRect.Height)) / 2 Then
Return GetCapsule(baseRect)
End If
Dim diameter As Single = radius * 2
Dim sizeF As SizeF = New SizeF(diameter, diameter)
Dim arc As RectangleF = New RectangleF(baseRect.Location, sizeF)
Dim path As GraphicsPath = New GraphicsPath()
path.AddArc(arc, 180, 90)
arc.X = baseRect.Right - diameter
path.AddArc(arc, 270, 90)
arc.Y = baseRect.Bottom - diameter
path.AddArc(arc, 0, 90)
arc.X = baseRect.Left
path.AddArc(arc, 90, 90)
path.CloseFigure()
Return path
End Function
**************************************

My question is...why is it when i use my custom rounded usercontrol and put
some textboxes on it. The controls on my usercontrol does not redraw
properly? i have to manualy tell my usercontrol to repaint itself. like....
Me.Refresh. Plrease help!
Nov 21 '05 #1
2 1950
What are ExtendedGraphics() and GetCapsule()?

Why not:
Me.Region = New Region(GetRoundedRect(rf, 5))

and what happens if you add the following to your OnPaint method?
MyBase.OnPaint(e)

I would recommend setting the region in the usercontrols OnResize method
rather than in the OnPaint method.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Jose Michael Meo R. Barrido" <mi**@rdmsinc.net> wrote in message
news:e4****************@TK2MSFTNGP11.phx.gbl...
I made a custom runded rectangle usercontrol. I used a function i found on
the internet. the function works fine(see "GetRoundRect" below).
I use the fullowing code to make my usercontrol rounded....
************************************************** ***
Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
Dim x1 As Integer = 0
Dim x2 As Integer = Me.ClientSize.Width
Dim iHeight As Int32 = Me.Height
Dim iWidth As Int32 = Me.Width
If bCurveSided Then
Dim eg As New ExtendedGraphics(e.Graphics)
Dim rf As New RectangleF()
With rf
.Width = iWidth
.Height = iHeight
.X = 1
.Y = 0
End With
Me.Region = New Region(eg.GetRoundedRect(rf, 5))
End If
End Sub

Public Function GetRoundedRect(ByVal baseRect As RectangleF, ByVal
radius As Single) As GraphicsPath
If radius <= 0 Then
Dim mPath As GraphicsPath = New GraphicsPath()
mPath.AddRectangle(baseRect)
mPath.CloseFigure()
Return mPath
End If
If radius >= (Math.Min(baseRect.Width, baseRect.Height)) / 2 Then
Return GetCapsule(baseRect)
End If
Dim diameter As Single = radius * 2
Dim sizeF As SizeF = New SizeF(diameter, diameter)
Dim arc As RectangleF = New RectangleF(baseRect.Location, sizeF)
Dim path As GraphicsPath = New GraphicsPath()
path.AddArc(arc, 180, 90)
arc.X = baseRect.Right - diameter
path.AddArc(arc, 270, 90)
arc.Y = baseRect.Bottom - diameter
path.AddArc(arc, 0, 90)
arc.X = baseRect.Left
path.AddArc(arc, 90, 90)
path.CloseFigure()
Return path
End Function
**************************************

My question is...why is it when i use my custom rounded usercontrol and
put some textboxes on it. The controls on my usercontrol does not redraw
properly? i have to manualy tell my usercontrol to repaint itself.
like.... Me.Refresh. Plrease help!

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.802 / Virus Database: 545 - Release Date: 26/11/2004
Nov 21 '05 #2
thanks for your advice. i'm gonna try that :-)

"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:O2****************@TK2MSFTNGP10.phx.gbl...
What are ExtendedGraphics() and GetCapsule()?

Why not:
Me.Region = New Region(GetRoundedRect(rf, 5))

and what happens if you add the following to your OnPaint method?
MyBase.OnPaint(e)

I would recommend setting the region in the usercontrols OnResize method
rather than in the OnPaint method.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Jose Michael Meo R. Barrido" <mi**@rdmsinc.net> wrote in message
news:e4****************@TK2MSFTNGP11.phx.gbl...
I made a custom runded rectangle usercontrol. I used a function i found
on the internet. the function works fine(see "GetRoundRect" below).
I use the fullowing code to make my usercontrol rounded....
************************************************** ***
Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
Dim x1 As Integer = 0
Dim x2 As Integer = Me.ClientSize.Width
Dim iHeight As Int32 = Me.Height
Dim iWidth As Int32 = Me.Width
If bCurveSided Then
Dim eg As New ExtendedGraphics(e.Graphics)
Dim rf As New RectangleF()
With rf
.Width = iWidth
.Height = iHeight
.X = 1
.Y = 0
End With
Me.Region = New Region(eg.GetRoundedRect(rf, 5))
End If
End Sub

Public Function GetRoundedRect(ByVal baseRect As RectangleF, ByVal
radius As Single) As GraphicsPath
If radius <= 0 Then
Dim mPath As GraphicsPath = New GraphicsPath()
mPath.AddRectangle(baseRect)
mPath.CloseFigure()
Return mPath
End If
If radius >= (Math.Min(baseRect.Width, baseRect.Height)) / 2 Then
Return GetCapsule(baseRect)
End If
Dim diameter As Single = radius * 2
Dim sizeF As SizeF = New SizeF(diameter, diameter)
Dim arc As RectangleF = New RectangleF(baseRect.Location, sizeF)
Dim path As GraphicsPath = New GraphicsPath()
path.AddArc(arc, 180, 90)
arc.X = baseRect.Right - diameter
path.AddArc(arc, 270, 90)
arc.Y = baseRect.Bottom - diameter
path.AddArc(arc, 0, 90)
arc.X = baseRect.Left
path.AddArc(arc, 90, 90)
path.CloseFigure()
Return path
End Function
**************************************

My question is...why is it when i use my custom rounded usercontrol and
put some textboxes on it. The controls on my usercontrol does not redraw
properly? i have to manualy tell my usercontrol to repaint itself.
like.... Me.Refresh. Plrease help!

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.802 / Virus Database: 545 - Release Date: 26/11/2004

Nov 21 '05 #3

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

Similar topics

2
by: Jose Michael Meo R. Barrido | last post by:
I made a custom runded rectangle usercontrol. I used a function i found on the internet. the function works fine(see "GetRoundRect" below). I use the fullowing code to make my usercontrol...
1
by: jimfortune | last post by:
The following Access VBA function creates a string that can be used in a pdf stream to draw or fill a rectangle of a given color with rounded corners: 'Begin code----------- Public Function...
3
by: Daisy | last post by:
I've started writing a listview, which currently draws my list to a pane, and onclick, works out which row you've clicked on, from the co-ordinates of the mouse, sets the .Selected property to the...
4
by: | last post by:
Please, help. I created my contol, ButtonX, which subclasses System.Forms.Windows.Button class. I am doing my own paiting, by overriding OnPaint and OnPaintBackground (without calling base...
8
by: Tinus | last post by:
Hello all, I've create a custom control (UserControl) and have a custom Item Collection. The control is a custom calendar which is draw using the Graphics Rectangle etc. functions. It is drawn...
5
by: Dag | last post by:
Hi all, I have a project where we use lots of user controls. We would like to move them to private assemblied custom controls but from what I see this can't be done because the .ascx file must...
2
by: Dino Buljubasic | last post by:
Hi, I have several panels that holds bunch of controls with information on my forms. My form has background image property set to an image that has borders defining where my panel comes and...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
6
by: moondaddy | last post by:
I need to be able to make polygons with rounded corners. This will be to draw group outlines around shapes in a diagramming tool in wpf. all angles in the polygon will be 90 degrees, but somehow...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.