Click here to Skip to main content
15,919,178 members
Home / Discussions / Visual Basic
   

Visual Basic

 
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 
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 
MicroVirus wrote:
Are you sure that the textbox control is actually *in* the groupbox? When debugging, check _ctrl.Parent to see if it refers to the groupbox.

Yes, I checked, it is inside it.

MicroVirus wrote:
Also, PutRedRectangle can only be called once


Thank you for this info, but my function create new Shape and new rectangle each time I call it (which is what I want for now) my next step (after fixing my current) is to remove the rectangle.

Well, you made me consider the .parent for the control I am sending and that help me to create a customized function if the .parent type is GroupBox

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.

    Dim _parent As Control = _ctrl.Parent
    rect1.Parent    = canvas
    canvas.Parent   = _parent
    canvas.Name     = "canvas_" + _ctrl.name
    ' Set the ShapeContainer as the parent of the RectangleShape.

    rect1.Width = _ctrl.Width + 2
    rect1.Height = _ctrl.Height + 2
    rect1.BorderWidth = 2
    ' Set the location and size of the rectangle.
    If TypeOf(_parent) is GroupBox 
        rect1.Left   = _ctrl.Left - 1  - _parent.Padding.Left 
        'rect1.Top   = _ctrl.Top  - 29 + (_parent.Margin.Top - _parent.Padding.Top) 'when using ms san seirf size 14
        rect1.Top    = _ctrl.Top  - 17 + (_parent.Margin.Top - _parent.Padding.Top) ' when using ms san seirf size 8
        rect1.BorderColor = Color.Red
    Else
        rect1.BorderColor = Color.Blue
        rect1.Left  = _ctrl.Left - 1 - _parent.Padding.Left
        rect1.Top   = _ctrl.Top  - 1 - _parent.Padding.Top
    End If
    canvas.SendToBack

End Sub
Sub RemoveRedRectangle(ByVal _ctrl As Control)
    Dim q = From c As Control In _ctrl.Parent.Controls Where c.Name.StartsWith("canvas_" + _ctrl.Name) Select c
    q.First.Dispose
    Me.Refresh
End Sub




It seem the groupbox has invisible header which should be calculated depends on the font size when assigning the .Top for the rectangle. ( I don't know how to get it)

Also, the Rect1.Top is affected with margin and padding if inside a groupbox, and it is not affected if inside a panel.

So, the above code works correctly so far.

Also the remove is working fine but I had to refresh the form

If any one has a suggestion or another idea, I will be thankful.

Thanks for your help
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 Pin
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 
GeneralRe: msdn Pin
Clark Kent12313-Sep-11 1:22
professionalClark Kent12313-Sep-11 1:22 
AnswerRe: msdn Pin
DaveAuld5-Sep-11 2:04
professionalDaveAuld5-Sep-11 2:04 

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.