Domanda

I have a custom Windows Forms (a class which extends System.Windows.Forms). Its layout is as follows:

enter image description here

  • FLP: Flow Layout Panel. Flow directions is specified in the name.
  • PB: Picture Box
  • RTB: RichTextBox
  • b: Button

    Onto the problem: it is possible for the FLP at the bottom to be empty (no buttons). When that happens, I'd like it to shrink to zero height, and let the FLP above, and the RTB, grow and fill that space. This is because all that empty space looks ugly when there are no buttons. I configured the lower flp with AutoSize = True and AutoSize = GrowAndShrink. Then, for the upper flp, I set AutoSize = True, AutoSizeMode = GrowOnly and Dock = Fill. But when I create a form with no buttons, the space is still there. If I draw the control borders, where the lower flp should be, I see a little square dot. Where am I going wrong?

UPDATE: I'm willing to redo the layout in a more convenient way, or even redo the whole form using WPF.

È stato utile?

Soluzione

I doesn't look like you need the Top-Down FlowLayoutPanel.

Try taking your Right-Left FlowLayoutPanel and Dock it to the bottom. Then take your Left-Right FlowLayoutPanel and Dock Fill it in the remaining area.

Where your button panel has no visible buttons, then you can just hide the panel and the Filled panel will take up that remaining space.

Altri suggerimenti

If you remove FLP_top_down, change flp_left_to_right to be .Dock = DockStyle.Fill and change flp_left_to_right to be .Dock = DockStyle.Bottom, you should get what you are after.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top