質問

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!

役に立ちましたか?

解決

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);
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top