如何使用c#给出像ms-word这样的行间距 [英] How to give line space like ms-word using c#

查看:169
本文介绍了如何使用c#给出像ms-word这样的行间距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我正在使用c#代码打印我的应用程序中的文本文件。

现在我希望行之间有1.5行间距。



请用c#告诉我怎么做。



谢谢

Hi all

I am printing a text file from my application using c# code.
now i want 1.5 line space between lines.

Please tell me how to do that using c#.

Thank you

推荐答案

文本文件只是一种约定:它们根本没有真正的线条概念 - 由处理它们的应用程序提供,通过查找它所认为的线条结束字符。这些因系统而异(在某些情况下甚至可能特定于应用程序)。在所有其他事项中,它们是二进制数据,它使用一组有限的可用值。



因此行间距的概念不是文本文件可以使用的:如果它不知道什么是线,它就无法分隔它!



如果你想把.TXT文件读到你的应用程序中并显示它确切如何更改间距取决于您用于显示数据的控件。对于多行文本框,我认为不可能,对于RichTextBox来说,它非常简单:更改RichTextBox控件中的行间距 [ ^ ]
Text files are just a convention: they have no "real" concept of lines at all - that is provided by the application which processes them, by looking for what it considers as "line end characters". And these vary from system to system (and can even bee application specific in some cases). In all other matters, they are binary data which uses a limited set of the available values.

So the concept of line spacing is not something a text file can work with: if it doesn't know what a "line" is, it can't space it!

If you are trying to read a .TXT file into you application and display it then exactly how you change the spacing depends on the control you are using to display the data. For a multiline textBox, I don't think it is possible, for a RichTextBox it's pretty simple: Changing the line spacing in a RichTextBox control[^]


要打印文本文件,可以使用PrintDocument class [ ^ ](WinForm),这可以设置几个属性。

在保存过程中不可能设置行间距。文本文件不包含有关格式化的信息(请参阅解决方案1)。



格式化文本的另一种方法是使用 html [ ^ ] + css styles [ ^ ]。
To print text files, you can use PrintDocument class[^] (WinForm), which enable to set several properties.
It's impossible to set "line-spacing" during the save process. Text file does not contains information about formatting (see solution 1).

Another way to format text is to use html[^] + css styles[^].


这篇关于如何使用c#给出像ms-word这样的行间距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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