473,725 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2547
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(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

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.m icrosoft.com> wrote in message
news:U%******** ********@cpmsft ngxa06.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
19779
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 test case element1 and element2 should be placed side by side inside a centered white container element: http://www.markusernst.ch/test.htm
3
11877
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 to-be-developed-function cmdOkay_Click() function as described below. 1. Create an user control that contains an OK button as below Public Class MyButton:System.Windows.Form.UserControl
3
25283
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 user control to invoke a method in the parent form. This code doesn't seem to work for me, I've tried it a number of times with very simple test cases (A user control with a single button and a parent form with a single text box) and it always...
6
6222
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 method from the mdichild, I get this error: C:\MyProjects\Visual Studio Projects\Tournament\Forms\frmLogin.cs(69): The name 'test' does not exist in the class or namespace 'Tournament.frmLogin' frmLogin is the mdichild.
2
1157
by: Brett | last post by:
This article explains that parenting controls is better than adding them to collections: http://msdn.microsoft.com/smartclient/understanding/netcf/dev/default.aspx?pull=/library/en-us/dnnetcomp/html/netcfimproveformloadperf.asp. However, it doesn't explain why. Please elaborate why parenting is better than using collections. Thanks, Brett
3
9701
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 parent menu functions. if i select draw line in MDI parent, the line should be drawn in current active child..any URLS for this or guide me to achieve this communication... -- Mähésh Kumär. R
0
4491
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. So, I tricked my Transparent Non-MDI Child form into my MDI-Container form via SetParent API as seen here in my VB.NET sample ( http://wuhenry.beigetower.org/position.zip ). I thought my problems are over, but apprently, even though I...
0
1125
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 SelectByPlan A 2 SPT A 3 SP A
1
1260
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. In this eg total 2 parent an 4 items are there. .By programitilly how can i Distingush. eg : <Container> <ContainerHandle>urn:epc:id:gid:49603356.41P.000001</ContainerHandle>
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.