Solved

How to make a usercontrol topmost (over the borders of it´s container)

Posted on 2010-09-13
17
1,042 Views
Last Modified: 2013-11-27
i have a usercontrol that behaves like a datetimepicker control. that means it can be dropped down. when i place it in the lower part of a groupbox and click on my usercontrol to show the calender, it is shown only from the top to the lowerborder of the groupbox. how can i have my control displayed  in the foreground (bringtofront() is not working by the way)

regards frank
0
Comment
Question by:michelsf
  • 8
  • 5
  • 3
  • +1
17 Comments
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33662212
this is something have to do with the anchor or the dock...
you can use
Me.GroupBox1.Controls.Add(UserControl)
        UserCOntrol.Dock = DockStyle.Top
0
 
LVL 7

Expert Comment

by:klakkas
ID: 33662370
When you place a control within a groupbox, only the part within the groupbox bounds will be visible. It is the same as having a control that is larger than the containing form: only the part of the form will be visible.

The only workaround I can think of is to use the Groupbox.parent property to get to the parent control and place your popup there.

For example:
Dim popup as new control

popup.left += GroupBox.left
popup.top += groupbox.top

groupbox.parent.controls.add (popup)

0
 

Author Comment

by:michelsf
ID: 33662417
sorry, anchor has no effect. dockstyle.top is not suitable for me. regrads frank
0
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 

Author Comment

by:michelsf
ID: 33662467
klakkas: thanky you for your idea, but that is not suitable for me.

but i do not agree with youwhat concerns the controls. e.g. the dropdownpart of a comboboxcontol can even be shown outside the bounds of the hole form !!! there must  be some kind of solution for my problem without moving the control. regrads frank
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33662529
ok try this and play with the dimenssions then
GroupBox1.Controls.Add(UserControl) ' Add the control to the Group which will automatically display it.

        GroupBox1.Anchor = AnchorStyles.Top

        GroupBox1.Anchor = AnchorStyles.Left

        UserControl.Top = GroupBox1.Height / 2 - UserControl.Height / 2
        UserControl.Left = GroupBox1.Width / 2 - UserControl.Width / 2

Open in new window

0
 

Author Comment

by:michelsf
ID: 33662586
jtoutou: thank you, but the calender has a fixed size and the usercontrol my not be moved.
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33662609
you need the user control in the top left of groupbox1 correct?
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33662633
Can you try this?
GroupBox1.Controls.Add(UserControl) 

        GroupBox1.Anchor = AnchorStyles.Top

        GroupBox1.Anchor = AnchorStyles.Left

        UserControl.Top = GroupBox1.Top - UserControl.Height
       UserControl.Left = GroupBox1.Left - UserControl.Left

Open in new window

0
 

Author Comment

by:michelsf
ID: 33662646
jtoutou: no not at all.

it should be shown over the borders of the groupbox (or any other containercontrol). like a combobox - when you drop down the list it will be shown topmost af all container wher it was placed, even the form is no limit. regards frank
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33662756
@Frank very sorry...
So you have a usercontrol .(DatetimePicker).You need When you drop the dtp to overlap other controls ?
0
 

Author Comment

by:michelsf
ID: 33662875
@jtoutou: exactly overlap is what i meant. i shoul overlap it´s own container, yes. it should behave like a comboboxcontrol.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 33663410
What version VB.Net are you working in?
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 33663518
Can you describe your usercontrol in more detail?

Snap answer is to host the "drop down" portion if your control in a separate borderless form that gets displayed from within the usercontrol.  This will allow it to extend beyond the confines of the main form and allow it to be positioned anywhere.  It does have other issues that have to be dealt with though (such as focusing and parenting).
0
 

Author Comment

by:michelsf
ID: 33670001
@Idle_Mind:

that´s what i figured myself. but how can it be done best ?  i do not want an additional form in my project. do you have a solution for the focusuing and parenting problems ?

the usercontrol is similar to the datetimepicker but has 2 additional buttons below the monthcalender.
it contains 1 textbox 1 lable  2 buttons 1 monthcalender and 1 panel

Regards Frank
0
 

Author Comment

by:michelsf
ID: 33680675
@all

I found my Solution here: http://lukesw.net/articles/SimplePopup.aspx

Regrads
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 33681712
Thanks for posting your solution!  I had found another site using a similar approach but hadn't had time to play with it yet...
0
 

Author Comment

by:michelsf
ID: 33683142
Thanks Idle_Mind
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Visual Studios 1 78
C#.NET MSVS 2010 is there some things not allowed in Background Worker DoWork? 27 37
MailAddress in vb 4 30
VB.net Open video relating to control 2 20
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question