FlowLayoutPanel request

0
0

Hi,

it is possibile in someway to auto center the controls in FlowLayoutPanel?

regards

Cristian Zerbinati

  • You must to post comments
0
0

The FlowLayoutEngine starts for the left on each new row. You can implement a custom layout by doing this:

 

  • Create a MyFlowLayoutPanel class extending FlowLayoutPanel
  • Create a MyFlowLayoutEngine class extending Wisej.Web.Layout.FlowLayoutEngine
  • Override the LayoutEngine property and return an instance (can be shared) of MyFlowLayoutEngine
  • Override MyFlowLayoutEngine.Layout(object container, WinForms.LayoutEventArgs layoutEventArgs) (add “using WinForms = System.Windows.Forms”)

 

public override bool Layout(object container, WinForms.LayoutEventArgs layoutEventArgs)

{

base.Layout(container, layoutEventArgs);

var panel = (FlowLayoutPanel)container;

// here you can go over all the controls in panel.Controls, detect the control in a single line and center it.

}

  • Cristian Zerbinati
    ok I try
  • Cristian Zerbinati
    Layout.FlowLayoutEngine it is not accessible because it is ‘Friend’ but no problem I do a solution for center the controls only after resize ends
  • Luca (ITG)
    You are right, sorry it’s internal. You’d have to override the basic Wisej.Web.LayoutEngine and then arrange the controls as you need them.
  • You must to post comments
0
0

Thank you Luca, useful reply.

But please look at the attached image, do you think there is no way to center the last key without use margins?

I would need that the buttons they center themselves when the control is resized, and wrap

 

Attachment
  • You must to post comments
1
0

The flow layout panel always lays out the children according to the flow direction. You can set the FillWeight property of child controls to make the fill the remaining space when wrapping. Together with MinSize, MaxSize and FlowBreak it’s a powerful layout container.

You can also use the FlexLayoutPanel setting the layout to either Vertical or Horizontal and with that one you can set the AlignX property.

All these containers (FlowLayoutPanel, TableLayoutPanel, FlexLayoutPanel) are also extenders: they add properties to their children in the designer. Look for FillWeight, AlignX, AlignY, FlowBreak, RowSpan, ColumnSpan, Row, Column, Cell. They should be under the “Layout” category.

Attachment
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.