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 10 2446
I want to anchor it so the listbox grows/shrinks vertically with the
resizing the splitcontainer.
What happens is it sizes the listbox horizontally about nearly the
same size
as the split container width.
If you only want it to grow vertically, then anchor it left or right,
but not both.
Marc
that worked.....but don't know why
"Marc Gravell" <ma**********@gmail.comwrote in message
news:ej**************@TK2MSFTNGP03.phx.gbl...
I want to anchor it so the listbox grows/shrinks vertically with the
resizing the splitcontainer.
What happens is it sizes the listbox horizontally about nearly the
same size
as the split container width.
If you only want it to grow vertically, then anchor it left or right, but
not both.
Marc
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
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" <ma***********@RemoveThis.optusnet.com.auwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
that worked.....but don't know why
"Marc Gravell" <ma**********@gmail.comwrote in message
news:ej**************@TK2MSFTNGP03.phx.gbl...
I want to anchor it so the listbox grows/shrinks vertically with the
resizing the splitcontainer.
What happens is it sizes the listbox horizontally about nearly the
same size
as the split container width.
If you only want it to grow vertically, then anchor it left or right, but not both.
Marc
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
}
}
}
});
}
}
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" <ma**********@gmail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>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
}
}
}
});
}
}
That does not compile
Yes it does - with a C# 3 compiler (I did state it was C# 3...).
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
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" <ma**********@gmail.comwrote in message
news:OM**************@TK2MSFTNGP04.phx.gbl...
>That does not compile
Yes it does - with a C# 3 compiler (I did state it was C# 3...).
>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
I can email you a screen dump if you need to see it
"Rotsey" <ma***********@RemoveThis.optusnet.com.auwrote in message
news:e6**************@TK2MSFTNGP05.phx.gbl...
>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" <ma**********@gmail.comwrote in message
news:OM**************@TK2MSFTNGP04.phx.gbl...
>>That does not compile
Yes it does - with a C# 3 compiler (I did state it was C# 3...).
>>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
Up to you... but the trick is to initialise the child controls with
sizes relative to their container.
Something like:
using System;
using System.Drawing;
using System.Windows.Forms;
static class Program
{
static void AddChild(Control parent, Control child, AnchorStyles
anchor) {
child.Left = parent.Padding.Left + child.Margin.Left;
child.Top = parent.Padding.Top + child.Margin.Top;
child.Height = parent.ClientSize.Height - child.Top
- parent.Padding.Bottom - child.Margin.Bottom;
child.Width = parent.ClientSize.Width - child.Left
- parent.Padding.Right - child.Margin.Right;
child.Anchor = anchor;
parent.Controls.Add(child);
}
[STAThread]
static void Main()
{
const AnchorStyles AnchorAll = AnchorStyles.Top |
AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
AnchorTopBottomLeft = AnchorStyles.Top |
AnchorStyles.Bottom | AnchorStyles.Left;
Application.EnableVisualStyles();
Form form = new Form();
SplitContainer vSplit = new SplitContainer();
vSplit.Orientation = Orientation.Vertical;
vSplit.Panel1.BackColor = Color.Tomato;
vSplit.Panel2.BackColor = Color.PowderBlue;
vSplit.SplitterWidth = 5;
AddChild(form, vSplit, AnchorAll);
TabControl tabs = new TabControl();
AddChild(vSplit.Panel2, tabs, AnchorAll);
TabPage page = new TabPage("Test");
tabs.TabPages.Add(page);
SplitContainer hSplit = new SplitContainer();
hSplit.Orientation = Orientation.Horizontal;
hSplit.SplitterWidth = 5;
hSplit.Panel1.BackColor = Color.PaleGreen;
hSplit.Panel2.BackColor = Color.PaleTurquoise;
AddChild(page, hSplit, AnchorAll);
ListBox lb = new ListBox();
lb.Items.AddRange(new object[] { "Foo", "Bar", "Blip", "Blop",
"Bleep" });
lb.IntegralHeight = false;
AddChild(hSplit.Panel1, lb, AnchorTopBottomLeft);
Application.Run(form);
}
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: nam |
last post by:
could someone please help me with this bizarre problem -
I've created a swf file at the top of my html page. The
swf file (using Swish) is simply a menu of 5 links to 5
anchor points on the html...
|
by: Astra |
last post by:
Hi everybody
Need your help.
I have a DB-extracted list of say 5 items per page, which have links on each
one that takes you to more detailed info on the 'clicked' particular item.
When you...
|
by: elsenraat_76 |
last post by:
Hello! I was wondering if someone could help me out with a problem I'm
having? I'm trying to input a javascript value into an anchor tag
(from a function), but don't have an event to call the...
|
by: Richard Brown |
last post by:
Ok, I celebrate and rejoice in the Anchor property. So wonderful compared
to the horrible 'resize' code I had to write in VB6, there is just no end to
the wonders of VB.NET..... uh, ok..... BUT......
|
by: gary |
last post by:
Hi,
I am trying to reference an anchor in a user control with a url. This
worked in 1.1 but no longer works in 2.0.
The ascx control is located in a "/include" folder
If you have a...
|
by: elibol |
last post by:
Hi,
Is there an event that fires when the back or forward button on a
browser is pressed? I need an event to fire when someone clicks the
back or forward button after an anchor has been set.
...
|
by: Randy Webb |
last post by:
The list below has the current section number, proposed anchor name, and
then the current title of that section. Some make sense, some don't.
There are a few that don't have proposed anchor names...
|
by: Meadock |
last post by:
Here's an example of what i'm trying to do.
At www.webpage.com/page1.php, there's a link that points to an anchor at www.webpage.com/page2.php. The syntax is: <a href="page2.php#anchor">Link</a>...
|
by: Rotsey |
last post by:
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...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |