问题
Working on a WinForms .Net 2.0 project, I need a checkbox to support multiple lines such that the box itself will be aligned to the top-left corner.
This is done using CheckAlign = System.Drawing.ContentAlignment.TopLeft
, which different from the default (MiddleLeft
).
When working with the default font this looks OK, but when the font becomes larger - what happens is that the gap above the text increases, yet the gap above the box itself remains constant.
The result is that the box appears above the text (see illustration below).
Any ideas?
I'd like to note that:
- I already tried a few option, such as using a custom designer, a TableLayoutPanel, etc., but didn't get far.
- .Net 2.0 is forced - upgrading is not an option.
Thanks in advance.

回答1:
The checkbox is actually aligned to the text. But in a way that could only please a typographer. It is just that a large font has more ascender height, the space where the diacritics go. Try "Ĥere's the problem". That's not something you can tinker. CheckedListBox also doesn't support owner draw, it is in general a pretty flawed control. If you don't want to use an ownerdraw ListBox then MiddleLeft or smaller fonts are the only decent options.

来源:https://stackoverflow.com/questions/10213792/top-left-box-alignment-on-a-multi-line-checkbox-with-a-large-font