我可以把红色加下划线吗? [英] Can I put red underline a String ?

查看:140
本文介绍了我可以把红色加下划线吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在文本框中为字符串加下划线。怎么回事?

I want to underline a string in a text box. how is it ?

推荐答案

Textbox不会帮助你,因为它只支持纯文本,你需要使用Rich Textbox控件,这样你才能实现你所获得的。

见下面的代码片段

Textbox will not help you to it as it supports only plain text, you need to use Rich Textbox control so that you can achieve what you get.
see below snippet
richTextBox1.SelectionFont = new Font("Times New Roman", 10, FontStyle.Underline);
richTextBox1.SelectedText = "Message:";
richTextBox1.SelectionFont = new Font("Times New Roman", 10, FontStyle.Regular);
richTextBox1.SelectedText = " This is a message for Name of Client.";


是的你肯定可以。您使用的是什么,WinForms,WPF还是Web?

根据这些,请查看以下链接:



如何制作粗体,斜体,下划线命令,更改文字 - asp.net.web-forms [ ^ ]

c# - Winforms - 在文本框中显示的文本的下划线 [ ^ ]

如何为字符串加下划线/文本在C#中分配了Control.Text属性以编程方式? [ ^ ]
Yes you surely can. What are u using, WinForms, WPF or Web ?
Depending on that, check these links:

how do i make a bold, italic, underline command,change text - asp.net.web-forms[^]
c# - Winforms - Underline part of text to be displayed in textbox[^]
How to underline a string/text assigned Control.Text property in C# programatically?[^]


请查看我对该问题的评论 - 这取决于文本框。字符串TextBox没有明确定义任何特定类型。在这个简单的名称下有许多类似但不相关的类型。这就是为什么我建议你在提问时至少使用一些完整的类型名称。



例如,对于ASP.NET,你可以使用CSS,对于其他情况,你使用一些样式属性,例如 FontStyle Font (具有自己的属性)。只需查看原始MSDN文档关于您要使用的确切类型



如果您使用XAML,您还可以编写整个样式 - 使用触发器和/或其他智能XAML技巧改变行为。 :-)



-SA
Please see my comment to the question — it depends on the type of TextBox. The string "TextBox" does not unambiguously define any certain type. There is a number of analogous but unrelated types under this simple name. That's why I recommended to use at least some full type names when you ask questions.

For example, for ASP.NET you can use CSS, for other cases, you use some style properties, such as FontStyle or Font (with its own properties). Just see original MSDN documentation on the exact type you want to use.

If you use XAML, you can also code the whole style-changing behavior using triggers and/or other "smart" XAML tricks. :-)

—SA


这篇关于我可以把红色加下划线吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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