2011-10-12 4 views
11

Tengo un control de flujo en winforms, he establecido su dirección de flujo en TopDown pero sigue agregando controles de izquierda a derecha, autoscroll también se establece en verdadero.flowlayout control sigue agregando control en la dirección incorrecta en winforms

flowLayoutPanel1.Controls.Clear();  
Label labelInput = new Label(); 
ListBox listBoxNewInput = new ListBox(); 

//Initialize label's property 
labelInput.Text = " #" + Convert.ToInt32(sequence); 
labelInput.AutoSize = true; 

//Initialize textBoxes Property 
listBoxNewInput.HorizontalScrollbar = false; 

listBoxNewInput.Items.Add(efforts); 
//Add the newly created text box to the list of input text boxes 
inputTextBoxesList.Add(listBoxNewInput); 

//Add the labels and text box to the form 
flowLayoutPanel1.FlowDirection = FlowDirection.TopDown; 
flowLayoutPanel1.Controls.Add(labelInput); 
flowLayoutPanel1.FlowDirection = FlowDirection.TopDown; 
flowLayoutPanel1.Controls.Add(listBoxNewInput); 
+0

lo que quiero es que si ellos no ajustarse verticalmente debe hacer una barra de desplazamiento, pero los pone a la derecha – PUG

Respuesta

23

establecer la propiedad WrapContents del flowLayoutPanel1 a false, que no permitirá mover los controles a la derecha, si no encajan. Con el fin de poder desplazarse contenido recortado se puede establecer AutoScroll propiedad a true

Aquí está el código:

flowLayoutPanel1.FlowDirection = FlowDirection.TopDown; 
flowLayoutPanel1.WrapContents = false; 
flowLayoutPanel1.AutoScroll = true; 
flowLayoutPanel1.Controls.Add(labelInput); 
flowLayoutPanel1.Controls.Add(listBoxNewInput); 
+1

OMG me llevaría semanas resolver esto sin que alguien diga directamente. aclamaciones – ErTR

Cuestiones relacionadas