标签中的文本格式 [英] Text formatting in Labels

查看:93
本文介绍了标签中的文本格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我必须在asp.net的数据库中的标签"上显示一些数据.但是不能显示换行符和不同的文本样式.所有数据都以相同的格式显示在一行中.您能帮我解决这个问题吗?
我正在使用C#编码.

谢谢...

Hi,
I have to display some data on Labels from the database in asp.net. But the newline character and different text styles cannot be displayed. All datas are appearing as same formatting and in a single line. Can you please help me for solving this problem.
I am using c# coding.

Thanking you...

推荐答案

同一标签的样式是否不同? Label类对您没有帮助;您需要一个不同的班级来做这样的事情.

这些组件之一可以为您提供帮助:
WPF HTML支持的文本块 [您将使用的专业HTML渲染器 [便携式方式.使用System.Environment.NewLine.

—SA
Different styles for the same label? The class Label won''t help you; you need a different class to do such things.

One of these components can help you:
WPF HTML Supported TextBlock[^],
A Professional HTML Renderer You Will Use[^].

Both works offer components based on HTML rendering, one for WPF, another for Forms. (Always tag UI library you want to use, don''t force people in doing double work.)

If you use the above components, new line will be <br/>. If you keep using plain-text labels, new line in general case is not ''\n'' or ''\r'' or combination. You need to use portable way. Use System.Environment.NewLine.

—SA


我不知道使用什么换行符.但是也许您可以将其替换为
I don''t know what newline character is used. But maybe you can replace it with
BtWhatever.Text = stringFromDB.Replace(dbNewlineChar, "\r\n");


如果仅换行符有问题,则可以使用< br>"代替"\ n",或者如果您希望在Lebel中使用任何其他特殊字符,图像等,则可以使用文字控件代替Label.
If you have problem only with newline character you can use "<br>" in place of "\n" or if you want any other special characters, images etc in your Lebel you can use Literal control in place of Label.


这篇关于标签中的文本格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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