473,396 Members | 1,724 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,396 software developers and data experts.

Retreiving Parent container size

Hi all!
I've created a personal control. This control is mainly a panel with some
other stuff in. I want to know if it's possible to know the size of the
container of this control? I mean that my control can be put on a form or a
panel. I want to know the size of the container without knowing what will be
exactly. It' possible?

Thank a lot

--
Francois Soucy
fs****@N.O.S.P.A.M.Altern.org
(enlever le "N.O.S.P.A.M.") pour réponse)
-----------------------------------------------------------------
"Je suis unique et spécial car je suis le seul à être moi..."
Nov 20 '05 #1
5 2531
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
Nov 20 '05 #2
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

Nov 20 '05 #3
Hi Francois,

It's not too late - your VS options have got the Parent property switched
off in the Intellisense. Type it in regardless and it will work. In fact
Intellisense will kick in as soon as you type the '.' after Parent.

In Tools/Options there's a Text Editor section click on that to get the
subsections and then click on Basic. You'll see an option Hide Advanced
Members. For you there will be a tick. This means that various methods that
you might want to use will be hidden by the Intellisense. They will still be
available if you type them but they won't show automatically. It's a question
of whether you want to see the whole list and have to do more scrolling, or do
you want to have to remember which methods are 'advanced'.

As I suggested, have a look at the Help for the Control Class - if it
gives a method there but you can't see it with Intellisense, believe the Help
and try it anyway.

Regards,
Fergus
Nov 20 '05 #4
Hi Francois,

Did Fergus's suggestion works for you?
If you have any concern on this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #5
No no! sorry! I was to busy with Halloween and my kid! This solution worked
fine for me! I was able to see parent container size and also it give me a
way to find a anwser of how to trap some parent event in my control :)
Thank!

Francois

"Peter Huang" <v-******@online.microsoft.com> wrote in message
news:U%****************@cpmsftngxa06.phx.gbl...
Hi Francois,

Did Fergus's suggestion works for you?
If you have any concern on this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #6

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

Similar topics

3
by: Markus Ernst | last post by:
Hello Reading the follwing document: http://www.w3.org/TR/WD-positioning-970131#In-flow it seems very clear that position:relative should be relative to the parent element. So in the following...
3
by: David N | last post by:
Hi All, I just wonder if in C#, I can develop a user defined control that can call its parent function which is not yet developed. For example, how do I make my user control call a...
3
by: Todd Schinell | last post by:
Back in July, Jeffery Tan posted this: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=OWOTdf0VDHA.2296%40cpmsftngxa06.phx.gbl In response as to how to get click events from a...
6
by: Claus Holm | last post by:
I'm trying to enable a menuitem in the parent form from a mdichild. Rather than making the menuitems public, I'd go for a public method in the parent form to do the change, but when I call the...
2
by: Brett | last post by:
This article explains that parenting controls is better than adding them to collections:...
3
by: Maheshkumar.R | last post by:
Hi groups, How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT. Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI...
0
by: Henry Wu | last post by:
Hi, I am aware that TransparencyKey only works with top-level forms or Non-MDI Child Forms, if one tries to set the opacity or transparencykey property to a MDI-Child form, it will have no effect....
0
by: yogeeswar | last post by:
HI ALL I AM USING DB2 8.1 AND I HAVE TWO TABLES PARENT TABLE 1)CODE IS PRIMARY KEY CODE CODE_DESC CATEGORY ----------- ----------------------------------------...
1
by: =?Utf-8?B?VW1lc2huYXRo?= | last post by:
Hi, I have a XML file which contains some Container and item information. Both the tag identying by the same tag (Container). But the outer is parent one and all other are child to that parent. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.