Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Anchor listbox problem

Reply
 
Old 04-30-2008   #1 (permalink)
Rotsey


 
 

Anchor listbox problem

Hi,

I have a Listbox in a Panel of SplitContainer.

I want to anchor it so the listbox grows/shrinks vertically with the
resizing the splitcontainer.

This is my code
What happens is it sizes the listbox horizontally about nearly the same size
as the split container width.


_TableList = new MdsListBox();

_TableList.Name = "TableList";
_TableList.Left = 10;
_TableList.Top = 40;
_TableList.Width = 150;
_TableList.Height = 100;
_TableList.Anchor = (AnchorStyles.Left | AnchorStyles.Right |
AnchorStyles.Bottom | AnchorStyles.Top);

I want the size of the listbox set here retained.

rotsey



My System SpecsSystem Spec
Old 04-30-2008   #2 (permalink)
Marc Gravell


 
 

Re: Anchor listbox problem

> I want to anchor it so the listbox grows/shrinks vertically with the
Quote:

> resizing the splitcontainer.
Quote:

> What happens is it sizes the listbox horizontally about nearly the
same size
Quote:

> as the split container width.
If you only want it to grow vertically, then anchor it left or right,
but not both.

Marc
My System SpecsSystem Spec
Old 04-30-2008   #3 (permalink)
Rotsey


 
 

Re: Anchor listbox problem

that worked.....but don't know why

"Marc Gravell" <marc.gravell@xxxxxx> wrote in message
news:ejy7hjpqIHA.1768@xxxxxx
Quote:
Quote:

> > I want to anchor it so the listbox grows/shrinks vertically with the
> > resizing the splitcontainer.
>
Quote:

> > What happens is it sizes the listbox horizontally about nearly the
> same size
Quote:

> > as the split container width.
>
> If you only want it to grow vertically, then anchor it left or right, but
> not both.
>
> Marc

My System SpecsSystem Spec
Old 04-30-2008   #4 (permalink)
Marc Gravell


 
 

Re: Anchor listbox problem

By anchoring it left | right, you are telling it to keep the left edge a
fixed distance from the container's left edge, and the right edge a
fixed distance from the container's right edge. Ihis means that it will
grow and shrink horizontally along with the container. If you don't want
it to track (grow and shirnk) the right hand edge, then don't anchor it
to the right hand edge.

Marc
My System SpecsSystem Spec
Old 04-30-2008   #5 (permalink)
Rotsey


 
 

Re: Anchor listbox problem

but now the listbox is anchored but part is not visiible under the second
panel

the listbox is the top panel

why can't it just stay where i set it to.....is this rocket science MS?

"Rotsey" <malcolm_smith@xxxxxx> wrote in message
news:%23gaj18pqIHA.4544@xxxxxx
Quote:

> that worked.....but don't know why
>
> "Marc Gravell" <marc.gravell@xxxxxx> wrote in message
> news:ejy7hjpqIHA.1768@xxxxxx
Quote:
Quote:

>> > I want to anchor it so the listbox grows/shrinks vertically with the
>> > resizing the splitcontainer.
>>
Quote:

>> > What happens is it sizes the listbox horizontally about nearly the
>> same size
Quote:

>> > as the split container width.
>>
>> If you only want it to grow vertically, then anchor it left or right, but
>> not both.
>>
>> Marc
>
>

My System SpecsSystem Spec
Old 04-30-2008   #6 (permalink)
Marc Gravell


 
 

Re: Anchor listbox problem

I don't understand what you mean "part is not visible under the second
panel"... it is starting at the height you give it: so give it the right
height! Or alternatively, set Dock to Left (much easier than managing
all the details manually).

A quick (C# 3) demo:

using System;
using System.Drawing;
using System.Windows.Forms;

static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form
{
Text = "Split Demo",
Controls =
{
new SplitContainer() {
Dock = DockStyle.Fill,
Orientation = Orientation.Horizontal,
Panel1 = {
BackColor = Color.Green,
Controls = {
new ListBox {
Dock = DockStyle.Left,
IntegralHeight = false,
BackColor = Color.Red,
Items = {
"Foo", "Bar", "Blip", "Blap", "Bloop"
}
}
}
}, Panel2 = {
BackColor = Color.Blue
}
}
}
});
}
}
My System SpecsSystem Spec
Old 04-30-2008   #7 (permalink)
Rotsey


 
 

Re: Anchor listbox problem

That does not compile

But it is not what I want

I have more just that control in the top panel of the splitcontainer.

So I have set the poistion and size of where I want the lb to start
and set the Anchor.Left , top bottom as you say.

But the bottom of the lb is not visible it is under the bottom panel

any more info would be grateful Marc.




"Marc Gravell" <marc.gravell@xxxxxx> wrote in message
news:%23BVS6OqqIHA.3804@xxxxxx
Quote:

>I don't understand what you mean "part is not visible under the second
>panel"... it is starting at the height you give it: so give it the right
>height! Or alternatively, set Dock to Left (much easier than managing all
>the details manually).
>
> A quick (C# 3) demo:
>
> using System;
> using System.Drawing;
> using System.Windows.Forms;
>
> static class Program
> {
> [STAThread]
> static void Main()
> {
> Application.EnableVisualStyles();
> Application.Run(new Form
> {
> Text = "Split Demo",
> Controls =
> {
> new SplitContainer() {
> Dock = DockStyle.Fill,
> Orientation = Orientation.Horizontal,
> Panel1 = {
> BackColor = Color.Green,
> Controls = {
> new ListBox {
> Dock = DockStyle.Left,
> IntegralHeight = false,
> BackColor = Color.Red,
> Items = {
> "Foo", "Bar", "Blip", "Blap", "Bloop"
> }
> }
> }
> }, Panel2 = {
> BackColor = Color.Blue
> }
> }
> }
> });
> }
> }

My System SpecsSystem Spec
Old 04-30-2008   #8 (permalink)
Marc Gravell


 
 

Re: Anchor listbox problem

> That does not compile

Yes it does - with a C# 3 compiler (I did state it was C# 3...).
Quote:

> I have more just that control in the top panel of the splitcontainer.
> ...
> But the bottom of the lb is not visible it is under the bottom panel
OK; how are you setting up the form? Are you using the Visual Studio
designer? If so, you should be able to simply resize (drag) the ListBox
as needed, and then set the Anchor...

Are you doing something different?

Marc
My System SpecsSystem Spec
Old 04-30-2008   #9 (permalink)
Rotsey


 
 

Re: Anchor listbox problem

I have a farily busy form

A splitContainer horizontal
In the right panel a tab control
then in a tap page I have my split container vertical
The in the top panel a another panel
It is in this panel of that I have my lb and other controls

Everything from the tabcontrol is added dymanically.

One issue I did have was setting the splitterdistance of the vertical
control
did not seem right I had to set it to 10. The panel hieght with its control
is actaully 145

I changed lb height to 5 and it is still actually about 100 and the bottom
is not visible.

Any ideas?


"Marc Gravell" <marc.gravell@xxxxxx> wrote in message
news:OMDixbqqIHA.1164@xxxxxx
Quote:
Quote:

>> That does not compile
>
> Yes it does - with a C# 3 compiler (I did state it was C# 3...).
>
Quote:

>> I have more just that control in the top panel of the splitcontainer.
> > ...
>> But the bottom of the lb is not visible it is under the bottom panel
>
> OK; how are you setting up the form? Are you using the Visual Studio
> designer? If so, you should be able to simply resize (drag) the ListBox as
> needed, and then set the Anchor...
>
> Are you doing something different?
>
> Marc

My System SpecsSystem Spec
Old 04-30-2008   #10 (permalink)
Rotsey


 
 

Re: Anchor listbox problem

I can email you a screen dump if you need to see it

"Rotsey" <malcolm_smith@xxxxxx> wrote in message
news:e6CSCjqqIHA.3680@xxxxxx
Quote:

>I have a farily busy form
>
> A splitContainer horizontal
> In the right panel a tab control
> then in a tap page I have my split container vertical
> The in the top panel a another panel
> It is in this panel of that I have my lb and other controls
>
> Everything from the tabcontrol is added dymanically.
>
> One issue I did have was setting the splitterdistance of the vertical
> control
> did not seem right I had to set it to 10. The panel hieght with its
> control is actaully 145
>
> I changed lb height to 5 and it is still actually about 100 and the bottom
> is not visible.
>
> Any ideas?
>
>
> "Marc Gravell" <marc.gravell@xxxxxx> wrote in message
> news:OMDixbqqIHA.1164@xxxxxx
Quote:
Quote:

>>> That does not compile
>>
>> Yes it does - with a C# 3 compiler (I did state it was C# 3...).
>>
Quote:

>>> I have more just that control in the top panel of the splitcontainer.
>> > ...
>>> But the bottom of the lb is not visible it is under the bottom panel
>>
>> OK; how are you setting up the form? Are you using the Visual Studio
>> designer? If so, you should be able to simply resize (drag) the ListBox
>> as needed, and then set the Anchor...
>>
>> Are you doing something different?
>>
>> Marc
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
click to url with anchor Vista mail
Easy to get handle from listbox. How to get listbox from handle? .NET General
windows live mail and anchor links Live Mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46