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(Im age)
Private Label As New TrapBox.Label(T exte)
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.Add Range(New System.Windows. Forms.Control() {icon,
Label})
'Location for icon box
Me.Position = (Me.Size.Width - Me.icon.Size.Wi dth) / 2
If Me.Position < 0 Then Me.Position = 0
Me.icon.Locatio n = New Drawing.Point(M e.Position, Me.Marge)
' Location for text label
Me.Position = (Me.Size.Width - Me.Label.Size.W idth) / 2
If Me.Position < 0 Then Me.Position = 0
Label.Location = New System.Drawing. Point(Me.Positi on, Me.Marge
+ Me.icon.Size.He ight + (Me.Marge / 2))
'############## ############### #########
'### THERE No parent property for me.(...) ###
Me.Size = New System.Drawing. Size( '???' , Me.Marge +
Me.icon.Size.He ight + Me.Label.Size.H eight + 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.ic o")
Dim Pan As New TrapBox.IconBox ("Hi this is a test?", Toto)
Me.Controls.Add Range(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.c om> wrote in message
news:us******** ******@TK2MSFTN GP11.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