HTML can be used in Java swing GUI components, like JTextBox
, JButton
, ... etc.
HTML可用于Java swing GUI组件,如JTextBox,JButton等。
Is there an equivalent to that in .NET (C#) WinForms? Or at least some simple way of making a single word bold inside a textbox without using another GUI component?
是否有与.NET(C#)WinForms相同的东西?或者至少是一些在不使用其他GUI组件的情况下在文本框中制作单个单词的简单方法?
3 个解决方案
#1
1
No, I don't think you can easily do that with a normal TextBox or Button. There are third party controls that might do that. WinForms is not a very extensible GUI framework at heart. If you are looking for that kind of capabilities, WPF is a great thing. WPF supports control composition and styling almost everywhere.
不,我认为你不能用普通的TextBox或Button轻松做到这一点。有第三方控件可能会这样做。 WinForms本身并不是一个非常可扩展的GUI框架。如果您正在寻找这种功能,WPF是一件好事。 WPF几乎支持所有控件组合和样式。
#2
3
For .Net you'll need to either use a RichTextbox control (and rtf formatting), embed a WebBrowser control, or inherit your own OwnerDrawn control from textbox.
对于.Net,您需要使用RichTextbox控件(和rtf格式),嵌入WebBrowser控件或从文本框继承自己的OwnerDrawn控件。
I would be surprised if there aren't third-party controls out there that do that last option for you, but there's nothing "official" for this and you'll have to evaluate them yourself.
如果没有第三方控件可以为你做最后一个选项,我会感到惊讶,但没有任何“官方”可供选择,你必须自己评估它们。
#3
1
One option would be to use a WPF TextBlock (I think) control which has support for basic formatting like HTML (but not HTML tag themselves).
一种选择是使用WPF TextBlock(我认为)控件,它支持像HTML这样的基本格式(但不支持HTML标签本身)。
#1
1
No, I don't think you can easily do that with a normal TextBox or Button. There are third party controls that might do that. WinForms is not a very extensible GUI framework at heart. If you are looking for that kind of capabilities, WPF is a great thing. WPF supports control composition and styling almost everywhere.
不,我认为你不能用普通的TextBox或Button轻松做到这一点。有第三方控件可能会这样做。 WinForms本身并不是一个非常可扩展的GUI框架。如果您正在寻找这种功能,WPF是一件好事。 WPF几乎支持所有控件组合和样式。
#2
3
For .Net you'll need to either use a RichTextbox control (and rtf formatting), embed a WebBrowser control, or inherit your own OwnerDrawn control from textbox.
对于.Net,您需要使用RichTextbox控件(和rtf格式),嵌入WebBrowser控件或从文本框继承自己的OwnerDrawn控件。
I would be surprised if there aren't third-party controls out there that do that last option for you, but there's nothing "official" for this and you'll have to evaluate them yourself.
如果没有第三方控件可以为你做最后一个选项,我会感到惊讶,但没有任何“官方”可供选择,你必须自己评估它们。
#3
1
One option would be to use a WPF TextBlock (I think) control which has support for basic formatting like HTML (but not HTML tag themselves).
一种选择是使用WPF TextBlock(我认为)控件,它支持像HTML这样的基本格式(但不支持HTML标签本身)。