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!

Was it helpful?

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);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top