Click here to Skip to main content
15,892,059 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: VB and MDB Pin
Luc Pattyn8-Sep-11 4:34
sitebuilderLuc Pattyn8-Sep-11 4:34 
AnswerRe: VB and MDB Pin
Eddy Vluggen8-Sep-11 6:57
professionalEddy Vluggen8-Sep-11 6:57 
QuestionRestore failed for Server '...\SQLEXPRESS' Pin
C#Coudou7-Sep-11 23:41
C#Coudou7-Sep-11 23:41 
AnswerRe: Restore failed for Server '...\SQLEXPRESS' Pin
Pradeep Shukla8-Sep-11 7:42
professionalPradeep Shukla8-Sep-11 7:42 
GeneralRe: Restore failed for Server '...\SQLEXPRESS' Pin
C#Coudou8-Sep-11 13:45
C#Coudou8-Sep-11 13:45 
AnswerRe: Restore failed for Server '...\SQLEXPRESS' Pin
Eddy Vluggen8-Sep-11 9:59
professionalEddy Vluggen8-Sep-11 9:59 
GeneralRe: Restore failed for Server '...\SQLEXPRESS' Pin
C#Coudou8-Sep-11 14:12
C#Coudou8-Sep-11 14:12 
QuestionPut red Rectangle arround control [modified] Pin
Sam Martini7-Sep-11 0:16
Sam Martini7-Sep-11 0:16 
Hi
I am trying to place a red rectangle around a control on a form using the PowerPacks RectangleShape.

I managed to do that if the control is on the form, but if the control is in container (groupbox, panel) i am getting wrong measurements.

Here is my code

VB
Sub PutRedRectangle(ByVal _ctrl As Control)
    Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
    Dim rect1 As New Microsoft.VisualBasic.PowerPacks.RectangleShape
    ' Set the form as the parent of the ShapeContainer.
    canvas.Parent = Me.GroupBox1 '' here is the wrong, if i changed that line to <code>canvas.Parent = Me</code> and put the textbox outside the groupbox, the rectangle will surround the textbox correctly.
    ' Set the ShapeContainer as the parent of the RectangleShape.
    rect1.Parent = canvas
    ' Set the location and size of the rectangle.
    rect1.Left = _ctrl.Left -1
    rect1.Top = _ctrl.Top - 1
    rect1.Width = _ctrl.Width + 2
    rect1.Height = _ctrl.Height + 2
    rect1.BorderWidth = 2
    rect1.BorderColor = Color.Red
End sub


If I placed a textbox on a form, the code will work
If I placed a textbox in groupbox on a form, the rectangle will not be placed correctly around the textbox.

Is there special calculations or formula I should follow?

[EDIT]
Any other way of placing a red rectangle around a control is welcomed.

modified on Wednesday, September 7, 2011 6:32 AM

GeneralRe: Put red Rectangle arround control Pin
MicroVirus7-Sep-11 0:51
MicroVirus7-Sep-11 0:51 
GeneralRe: Put red Rectangle arround control Pin
Sam Martini7-Sep-11 5:50
Sam Martini7-Sep-11 5:50 
Questiona situation with connection string Pin
alejx6-Sep-11 13:17
alejx6-Sep-11 13:17 
AnswerRe: a situation with connection string Pin
Pradeep Shukla6-Sep-11 19:32
professionalPradeep Shukla6-Sep-11 19:32 
GeneralRe: a situation with connection string Pin
alejx7-Sep-11 2:07
alejx7-Sep-11 2:07 
GeneralRe: a situation with connection string Pin
Pradeep Shukla7-Sep-11 3:37
professionalPradeep Shukla7-Sep-11 3:37 
GeneralRe: a situation with connection string Pin
alejx7-Sep-11 4:34
alejx7-Sep-11 4:34 
GeneralRe: a situation with connection string Pin
Pradeep Shukla7-Sep-11 4:41
professionalPradeep Shukla7-Sep-11 4:41 
GeneralRe: a situation with connection string Pin
alejx7-Sep-11 5:11
alejx7-Sep-11 5:11 
GeneralRe: a situation with connection string [modified] Pin
Pradeep Shukla7-Sep-11 8:36
professionalPradeep Shukla7-Sep-11 8:36 
GeneralRe: a situation with connection string Pin
alejx7-Sep-11 12:59
alejx7-Sep-11 12:59 
GeneralRe: a situation with connection string Pin
Pradeep Shukla7-Sep-11 13:03
professionalPradeep Shukla7-Sep-11 13:03 
AnswerRe: a situation with connection string Pin
Simon_Whale6-Sep-11 22:15
Simon_Whale6-Sep-11 22:15 
Questionmsdn Pin
Shahab Mohammadi4-Sep-11 22:42
Shahab Mohammadi4-Sep-11 22:42 
AnswerRe: msdn PinPopular
Dalek Dave4-Sep-11 22:52
professionalDalek Dave4-Sep-11 22:52 
GeneralRe: msdn Pin
Clark Kent12312-Sep-11 9:13
professionalClark Kent12312-Sep-11 9:13 
GeneralRe: msdn Pin
Dave Kreskowiak12-Sep-11 9:26
mveDave Kreskowiak12-Sep-11 9:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.