C# 格式化 MessageBox
我想显示一个消息框,提醒用户该过程已完成,并详细说明该过程每个阶段花费的时间。我已经得到了想要显示的文本,并设置了适当的格式,但 MessageBox 类的默认字体不是单宽的。据我所知,无法指定文本显示的字体。
是否有一个开箱即用的库可供我用于此目的,或者我是否必须自己编写一个?
I want to display a MessageBox alerting the user that the process is complete, and giving a breakdown on how long each stage of the process took. I've got the text that I want to display formatted appropriately, but the default font of the MessageBox class is not mono-width. As far as I can tell, there's no way to specify the font that the text displays with.
Is there an out-of-the-box library somewhere that I can use for this, or am I going to have to write one up myself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
听起来您可能只想在其中放置一个新表单并使用一些标签。
Sounds like you may just want to drop a new form in there and use a few labels..
我用这个:
I use this:
有什么理由不直接使用等宽字体创建一个带有文本框/标签的
Form
,然后调用Form.ShowDialog
?听起来像一个单独的图书馆对我来说有点过分了。Any reason not to just create a
Form
with a textbox/label using a monospace font, then callForm.ShowDialog
? Sounds like a separate library with that would be overkill to me.根据记录,这实际上是可能的,MessageBox() 扩展选项卡。例如:
如果字宽开始接近制表符宽度,则不太值得信赖。您仍然应该更喜欢带有 ListView 的小助手表单。
For the record, this is in fact possible, MessageBox() expands tabs. For example:
It isn't very trustworthy if the word width starts to approach the tab width. You still should prefer a little helper form with a ListView.
我刚刚用可更改的字体编写了 MessageBox 的单个文件替换。您可以在此处下载它并像标准 MessageBox 一样使用它:
http://www.codeproject.com/Articles/601900/FlexibleMessageBox-A-flexible-replacement-for-the
问候,约尔格
I have just written a single file replacement for MessageBox with a changeable font. You can download it here and use it like a standard MessageBox:
http://www.codeproject.com/Articles/601900/FlexibleMessageBox-A-flexible-replacement-for-the
Regards, Jörg