如何使引号中的文本变为粗体 [英] How to make the text bold which is in quotations

查看:252
本文介绍了如何使引号中的文本变为粗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我认为这是一个基本问题,但我仍在发帖,因为我未能如何在谷歌搜索我的查询而我认为我可以框架我题。我是.net的新手。

所以我正在完成一些任务,我得到的代码很少,如下所示。我需要中的文字应该是粗体,结果将是正常的。



代码1:



AB + =短文+ ac.value;

AB + =LONG TEXT+ ac.value;



代码2:



string builder sb = new stringbuilder();

sb.appendline(NAME:\t+ name.value );

sb.appendline(PLACE:\t+ place.value);



在secnod案例中,我是从项目中间开始工作,所以我不确定用什么来使文本(NAME和PLACE)变粗。



任何帮助都将不胜感激。



我尝试了什么:



尝试谷歌搜索,但我的问题的框架是坏。

解决方案

字符串没有与之关联的任何格式 - 它不能是粗体或加下划线,甚至不是Times New Roman - 它实际上只是一系列字符。

格式化只是一个当它被呈现给输出设备时,无论是浏览器,表单还是打印机 - 然后应用该格式的方法将因输出设备而异。对于网页,加粗文字意味着在其周围添加粗体标签:

这是正常的<   b  > 这是粗体<   / b  > 这是正常现象



对于打印,您需要使用Graphics.DrawString三次,中间有一个粗体字体,这很复杂,因为您需要测量字符串以确保在打印时将它们定位在页面上的正确位置对于相同的字体和大小,粗体字符比非粗体更宽。

对于WinForms应用程序,情况更糟:您无法将格式应用于TextBox或Label中字符串的任何部分控制,但可以在RichTextBox中提供你在字符串中包含RTF代码。



所以不,这不是一个基本问题 - 它是v ery,根据您正在工作的环境,远非一个简单的解决方案。


正如OriginalGriff所提到的,解决方案取决于您要实现的目标。



假设您将一些数据存储在xml文件中,并且您希望为最终用户显示该数据。您可以使用xsl转换,这使您可以从xml创建html文档 [ ^ ]。请检查一下:

你好,世界! (XSLT) [ ^ ]

如何将XSL转换应用于XML文档使用Visual C# [ ^ ]

Hi,

I think this is a basic question but still i am posting because i failed how to search my query in google instead i thought i can frame my question. I am new to .net.
So i am working on some task where i got few lines of code as shown below. I need the text in "" should be bold and the result will be anyway normal.

Code 1:

AB+= " SHORT TEXT " + ac.value;
AB+= " LONG TEXT " + ac.value;

Code 2:

string builder sb = new stringbuilder();
sb.appendline("NAME:\t" + name.value);
sb.appendline("PLACE:\t" + place.value);

In the secnod case, i am working from middle of the project so i am not sure what to use to make the text (NAME and PLACE) bold.

Any help would be appreciated.

What I have tried:

Tried googling but the framing of my question is bad.

解决方案

A string doesn't have any formatting associated with it - it can't be "bold" or "underlined" or even "Times New Roman" - it's is literally just a sequence of characters.
Formatting is only applied when it is presented to an output device, be that a browser, a form, or a printer - and then the method to apply that formatting will vary from output device to output device. For a webpage, to boldify text would mean adding bold tags round it:

this is normal <b>this is bold</b> this is normal again


For printing, you would need to use Graphics.DrawString three times, with a Bold font in the middle, and that's complicated because you need to measure the strings to make sure you are locating them in the right place on the page when you print them - bold characters are wider than non bold for the same font and size.
For a WinForms app, it's even worse: you can't apply formatting to any part of a string in a TextBox or Label control, but can in a RichTextBox provided you include RTF code in your string.

So no, it's not a "basic" question - and it's very, very far from a trivial solution depending on the environment you are working in.


As OriginalGriff mentioned, a solution depends on what you're trying to achieve.

Let say, you store some data in xml file and you'd like to display that data for end-user. You can use xsl transformation, which enables you to create html document from xml[^]. Please, check this:
Hello, World! (XSLT)[^]
How to apply an XSL transformation to an XML document by using Visual C# [^]


这篇关于如何使引号中的文本变为粗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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