![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Quote: > as the split container width. but not both. Marc |
My System Specs![]() |
| | #3 (permalink) |
| | 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 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | 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 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 Specs![]() |
| | #6 (permalink) |
| | 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 Specs![]() |
| | #7 (permalink) |
| | 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 Specs![]() |
| | #8 (permalink) |
| | 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 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 Specs![]() |
| | #9 (permalink) |
| | 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 Specs![]() |
| | #10 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||