473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

ListBox size not growing to fill increased size of FlowLayoutPanel

I have a form.

In the Form is a MenuStrip and a FlowLayoutPanel.

In the FlowLayoutPanel is a ListBox.

The FlowLayoutPanel is set to DockStyle.Fill.
The ListBox is set to AnchorStyles.Left | AnchorStyles.Right

I am able to verify that the FlowLayoutPanel grows in size as the form
is widened. But the ListBox stays the same size. It does not anchor
to the left and right.

When I place the ListBox directly in the Form and drop the
FlowLayoutPanel and the MenuStrip the ListBox does widen as the form
is widened.

How do I get the ListBox in the FlowLayoutPanel to increase in size as
the FlowLayoutPanel is widened?

thanks,
mFlow = new FlowLayoutPanel();
mFlow.Parent = this;
mFlow.AutoSize = true;
mFlow.Dock = DockStyle.Fill;

mMenu = new MenuStrip();
mMenu.Parent = this;
ToolStripMenuItem item =
(ToolStripMenuItem)mMenu.Items.Add("&Commands", null,
CommandsOnClick);
item = (ToolStripMenuItem)mMenu.Items.Add("FlowSize", null,
FlowSizeOnClick);

mListBox1 = new ListBox();
mListBox1.Parent = mFlow;
mListBox1.Size = mFlow.ClientSize;
mListBox1.Location = new Point(0, 0);
mListBox1.Anchor = AnchorStyles.Right | AnchorStyles.Left ;

Mar 4 '07 #1
1 7464
more code to illustrate the problem:

public Form1()
{
InitializeComponent();

// the ListBox does not widen as I widen the form.
FlowLayoutPanel flow = AddFlowLayoutToForm(this);
AddListBoxToControl(flow);
return ;

// if this code is run, the ListBox does widen as the form is widened.
AddListBoxToControl( this ) ;

}
public FlowLayoutPanel AddFlowLayoutToForm(Form InForm)
{
FlowLayoutPanel flow = new FlowLayoutPanel();
flow.Parent = InForm;
flow.Dock = DockStyle.Fill;
flow.Click += Click_ObjectPropertyGrid;
return flow;
}

public ListBox AddListBoxToControl(Control InControl)
{
ListBox box1 = new ListBox();
box1.Parent = InControl;
box1.Size = InControl.ClientSize;
box1.Location = new Point(0, 0);
box1.Anchor = AnchorStyles.Left | AnchorStyles.Right;
box1.Click += Click_ObjectPropertyGrid;
box1.Font = new Font("Lucida Console", box1.Font.Size + 3);
box1.ForeColor = Color.Brown;

for (int ix = 1; ix <= 30; ++ix)
{
box1.Items.Add(
"text line number " + ix.ToString() +
" " + box1.ToString( ));
}
return box1;
}

void Click_ObjectPropertyGrid(object objSrc, EventArgs args)
{
Control ctrl = (Control)objSrc;

Form form = new Form();
form.Text = ctrl.ToString();
form.Owner = this;

PropertyGrid prop = new PropertyGrid();
prop.SelectedObject = objSrc;
prop.Parent = form;
prop.Dock = DockStyle.Fill;

form.Show();
}

On Mar 3, 11:54 pm, "Steve Richter" <StephenRich...@gmail.comwrote:
I have a form.

In the Form is a MenuStrip and a FlowLayoutPanel.

In the FlowLayoutPanel is a ListBox.

The FlowLayoutPanel is set to DockStyle.Fill.
The ListBox is set to AnchorStyles.Left | AnchorStyles.Right

I am able to verify that the FlowLayoutPanel grows in size as the form
is widened. But the ListBox stays the same size. It does not anchor
to the left and right.

When I place the ListBox directly in the Form and drop the
FlowLayoutPanel and the MenuStrip the ListBox does widen as the form
is widened.

How do I get the ListBox in the FlowLayoutPanel to increase in size as
the FlowLayoutPanel is widened?

thanks,

mFlow = new FlowLayoutPanel();
mFlow.Parent = this;
mFlow.AutoSize = true;
mFlow.Dock = DockStyle.Fill;

mMenu = new MenuStrip();
mMenu.Parent = this;
ToolStripMenuItem item =
(ToolStripMenuItem)mMenu.Items.Add("&Commands", null,
CommandsOnClick);
item = (ToolStripMenuItem)mMenu.Items.Add("FlowSize", null,
FlowSizeOnClick);

mListBox1 = new ListBox();
mListBox1.Parent = mFlow;
mListBox1.Size = mFlow.ClientSize;
mListBox1.Location = new Point(0, 0);
mListBox1.Anchor = AnchorStyles.Right | AnchorStyles.Left ;

Mar 4 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Brett L. Moore | last post by:
Hi, I have had trouble determining whether the STL list.size() operation is O(1) or O(n). I know the list is a doubly-linked list, so if the size() operation begins at the head, then counts to...
1
by: Annette Massie | last post by:
I would like to have a form that lists current addresses being used. On this form I would also like to have a command button that would allow the user to add an address if they do not see it...
0
by: Sin Jeong-hun | last post by:
If FlowLayoutPanel's AutoScroll is set to true, there appears a scroll bar on the right. Normally, users would expect the contents is scrolled while they are dragging the scroll bar. Well, it does,...
2
by: DC Gringo | last post by:
I have two listboxes, the first of which is an autopostback=true that allows multiple row selection. When I select multiple values (by holding down CTL) in the first one, it should query the...
7
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but...
1
by: Liam J | last post by:
Is there an upper limit on what FlowLayoutPanel will display? I wrote a test that adds 395 buttons to a flowlayoutpanel and it stopped displaying them after button 310, cutting 310 in half. It...
3
by: Ali Chambers | last post by:
Hi, I have created a listbox called "dtlist1" on my VB.NET form. I call a procedure as follows: Private Sub openfile(flname As String) dtlist1.Items.Clear() etc..
3
by: ThunderMusic | last post by:
Hi, I want to make a toolbox form (like the one in Adobe Photoshop), so I would like to put many buttons one beside the others (beside, over and under, just like the toolbox in photoshop). I...
5
by: Joe C. | last post by:
hello, thanks for reading. this topic was probably covered in the past; if so, i apologize for the repost, and would you kindly redirect me to the topic? i have small app that monitors the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.