473,385 Members | 1,622 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,385 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!
Jul 21 '05 #1
2 2171
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
Jul 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

Jul 21 '05 #3

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

Similar topics

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...
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...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.