Top-Left box alignment on a multi-line CheckBox with a large font

耗尽温柔 提交于 2019-12-24 02:14:46

问题


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:

  1. I already tried a few option, such as using a custom designer, a TableLayoutPanel, etc., but didn't get far.
  2. .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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!