|
-
Jul 10th, 2018, 06:19 PM
#1
Thread Starter
PowerPoster
RESOLVED - Position listbox below textbox
Hello, hoping to get some help on the following:
I have a textbox and a button inside a panel.
When I click the button, I would like to position a listbox below the textbox, where the listbox "floats independently" of the panel; i.e. so that the listbox is not contained in the panel, and if its height extends past the end of the panel, so be it.
Sample code would be great ...
Thanks,
Bruce
Last edited by BruceG; Jul 10th, 2018 at 07:35 PM.
Reason: resolved
"It's cold gin time again ..."
Check out my website here.
-
Jul 10th, 2018, 06:37 PM
#2
Re: Position listbox below textbox
If you don't want the ListBox restricted by the Panel then don't add it to the Panel. If you add the ListBox to the form then it can appear anywhere within the form. You should probably add the ListBox to the form in the designer and get the position right that way, then simply Show and Hide the ListBox as required. If you want to actually create the ListBox at run-time, you just have to do a bit of jiggery-pokery to get the position correct, e.g.
vb.net Code:
'Get the position of the TextBox relative to the form. Dim textBoxLocation = PointToClient(Panel1.PointToScreen(TextBox1.Location)) Dim lb As New ListBox 'Position the ListBox directly below the TextBox. lb.Location = New Point(textBoxLocation.X, textBoxLocation.Y + TextBox1.Height + TextBox1.Margin.Bottom + lb.Margin.Top)
-
Jul 10th, 2018, 07:34 PM
#3
Thread Starter
PowerPoster
Re: Position listbox below textbox
Beautiful - thanks very much!
"It's cold gin time again ..."
Check out my website here.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|