【发布时间】:2021-01-25 13:54:52
【问题描述】:
我正在尝试在 WinForms 按钮 87x30 大小的文本之前添加 .ico 48x48 图像:
button1.BackgroundImageLayout = ImageLayout.Stretch;
button1.BackgroundImageLayout = ImageLayout.None;
button1.BackgroundImageLayout = ImageLayout.Zoom;
button1.ImageAlign = ContentAlignment.MiddleLeft;
button1.TextImageRelation = TextImageRelation.ImageBeforeText;
button1.TextAlign = ContentAlignment.MiddleRight;
结果是:
我想弄清楚,如何将左侧的图像与相关距离上的文本对齐,如下所示:
编辑:
button1.TextImageRelation = TextImageRelation.ImageBeforeText;
button1.TextAlign = ContentAlignment.MiddleLeft; /// MiddleRight; // MiddleCenter;
button1.ImageAlign = ContentAlignment.MiddleRight; /// MiddleLeft;
结果:
【问题讨论】:
-
看起来您正在混合 Image 和 BackgroundImage?
-
你应该将
Image属性设置为一个图像,然后ImageAlign和TextAlign都应该设置为MiddleLeft,TextImageRelation应该是ImageBeforeText。 -
我想知道 Image before the text 应该是什么意思:z.order 或水平放置..
-
水平/垂直对齐。
标签: c# winforms button ico iconbutton