Maybe it's to late in the nite and I can't see anything... But I'could not
find any parent property! I show you what i've done:
Class TrapBox
Public Class IconBox
Inherits Panel
Private Marge As Integer = 10 ' Margin
Private Largeur As Integer = 10
Private Position As Integer
Private icon As New TrapBox.Icon(Image)
Private Label As New TrapBox.Label(Texte)
Sub New(ByVal Texte As String, ByVal Image As Image)
'TODO Enlever le back Color a la fin...
Me.BackColor = System.Drawing.Color.Aqua 'Only for debuging
purpose... Remove at end
Me.Controls.AddRange(New System.Windows.Forms.Control() {icon,
Label})
'Location for icon box
Me.Position = (Me.Size.Width - Me.icon.Size.Width) / 2
If Me.Position < 0 Then Me.Position = 0
Me.icon.Location = New Drawing.Point(Me.Position, Me.Marge)
' Location for text label
Me.Position = (Me.Size.Width - Me.Label.Size.Width) / 2
If Me.Position < 0 Then Me.Position = 0
Label.Location = New System.Drawing.Point(Me.Position, Me.Marge
+ Me.icon.Size.Height + (Me.Marge / 2))
'######################################
'### THERE No parent property for me.(...) ###
Me.Size = New System.Drawing.Size( '???' , Me.Marge +
Me.icon.Size.Height + Me.Label.Size.Height + Me.Marge)
End Sub
......
End Class
End Class
#### End snip ###
I know that how my control is created may cause my probleme. i call it this
way in my form.
Dim Toto As New System.Drawing.Bitmap("test.ico")
Dim Pan As New TrapBox.IconBox("Hi this is a test?", Toto)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Pan})
Pan.Location = New Drawing.Point(0, 0)
' I don't want to size (width) the control there. He MUST be the same size
(width) than the parent...
"Fergus Cooney" <fi*****@post.com> wrote in message
news:us**************@TK2MSFTNGP11.phx.gbl...
Hi Francois,
Guess what! Every Control has a Container property. Hurray!!
But it's useless for what you want. :-(
Yet they have a Parent property, too, and this is <just> what you
want. :-)
And as Parent will be a Control, it'll have a Size and a ClientSize.
Ha! Now we're talking!! ;-))
Have you looked at the Help page for the Control class? There are
<loads> of properties to play with.
Regards,
Fergus