Vista样式按钮行为-自动省略号 [英] Vista Style Button Behavior - Auto Ellipsis

查看:72
本文介绍了Vista样式按钮行为-自动省略号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我的C#项目上有一个用于Vista样式按钮的UserControl类.该按钮的属性为:

Hello

I have a UserControl class for Vista Style Button on my C# Project. The properties for this button are:

BaseColor
BackImage
ButtonColor
ButtonStyle
CornerRadius
GlowColor
HighlightColor
Image
ImageAlign
ImageSize
ButtonText
TextAlign



有人可以帮我创建一个名为 AutoEllipsis
的行为吗?
在此先感谢


lapeci



Can someone help me create a property Behavior called AutoEllipsis

thanks in advance


lapeci

推荐答案

如果控件继承自按钮类,则可以使用按钮类本身的AutoEllipsis属性.
否则,您将必须对文本执行MeasureString并将其宽度与控件的宽度进行比较.如果文本宽度大于控件的宽度,请获取合适的子字符串,然后放置"...".您还应该实现一个工具提示,以便在鼠标悬停时显示全文.
If your controls inherits from button class, you can use the AutoEllipsis property of the button class itself.

Otherwise, you will have to do MeasureString on the text and compare the width it with the width of control. If the text width is more than controls, get a suitable substring of it and place "...". You should also implement a tooltip so that full text is shown with mouse hover happens.


这篇关于Vista样式按钮行为-自动省略号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆