I'm having something like this:
class MyPanel : FlowLayoutPanel
{
public MyPanel()
{
this.BackColor = Color.Red;
this.FlowDirection = System.Windows.Forms.FlowDirection.LeftToRight;
listBox = new ListBox();
editButton = new Button();
//editButton.Click += editButton_Click;
this.Controls.Add(listBox);
this.Controls.Add(editButton);
}
}
and then I'm adding it into my form dynamically. The problem is the listBox is overlapping the button. However if I try to add there 2 buttons instead of list it is working as it is supposed to - buttons are organized in 1 line from left to right. I want to reach the button to be next to the list. Can somebody advice me? Thanks
Try This Code:
class MyPanel : FlowLayoutPanel
{
public MyPanel()
{
this.BackColor = Color.Red;
this.FlowDirection = System.Windows.Forms.FlowDirection.LeftToRight;
listBox = new ListBox();
this.WrapContents = false; // Use this for control not wrapped
editButton = new Button();
this.Controls.Add(listBox);
this.Controls.Add(editButton);
}
}