Question

I need to add some RadioButtons to a FlowLayoutPanel.

If I leave radio buttons' properties as default, it will fine. But if I set CheckAlign = ContentAlignment.TopCenter, it will go wrong, like this

Wrong display on flow layout panel

Here's my code:

for (int i = 0; i < 2; ++i) {
    RadioButton opt = new RadioButton() {
        Text = "Test",
        CheckAlign = ContentAlignment.TopCenter
    };

    pnlPassNumbers.Controls.Add(opt);
}

Anybody know how was it wrong? Thanks!

Était-ce utile?

La solution

You don't describe actually what is the wrong part. That is, should the text be aligned to the left of the mark, or below it?

for (int i = 0; i < 2; ++i) {
    RadioButton opt = new RadioButton() {
        Text = "Test",
        CheckAlign = ContentAlignment.TopCenter,
        TextAlign = ContentAlignment.BottomCenter.
        Size = new Size(86, 36)
    };

    pnlPassNumbers.Controls.Add(opt);
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top