开发者

Button TextImageRelation and TextAlign problem

When using a Button in my projects... they expose a property called TextImageRelation. This is used to tell the control where to place the button image in relation with the text (I'm using the ImageBeforeText option). Now, I need to have the text aligned to the center.

The logic outcome I would spect is: an image aligned to the left and the button text centred in the space between the image and the right borde开发者_运维百科r of the button.

But not... the text is aligned next to the image OR aligned to center but not taking into account the image (not sure which case).

There is a way to change this behavior?


Unfortunately you can't. The layout is determined by the internal ButtonBaseAdapter.CommonLayout() method, you can't override it.

TextImageRelation = Overlay aligns the Text according to the TextAlign setting. The image is ignored.

Once you set TextImageRelation = ImageBeforeText then the Text is always aligned flush to the right of the image. The gap size is fixed, 3 pixels. A very silly but otherwise effective way to move the text to the right is to prefix the Text with spaces. Not good enough to ensure it is centered though. You'd normally wouldn't want this anyway, button captions ought to line up. Note that RightToLeft = Yes gives you more ways to tinker, just not what you are looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜