在 winform RichTextBox 中更改行距 [英] Change line spacing in winform RichTextBox

查看:70
本文介绍了在 winform RichTextBox 中更改行距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 winform 项目中使用 RichTextBox 控件来显示一种旧的控制台屏幕.这很完美,但线条之间有一个空格.是否可以将此空间更改为 0 或接近该值的任何值.如果我从第 1 行到第 5 行的垂直线画一条线,我不希望线之间有任何间距.

I'm using in my winform project a RichTextBox control to display a kind of old console screen. This works perfectly but there is a space between the lines. Is it possible to change this space to be 0 or anything near that. If i paint a line from vetical line from line 1 to line 5 i don't want any spacing between the line.

希望你能帮助我.

推荐答案

实际上有很多 Windows 窗体 RichTextBox 没有公开.如果您有控件的 HWND(句柄属性),您可以使用 SendMessage API 发送 EM_SETPARAFORMAT 消息以播放格式.

There's actually a lot that the Windows Forms RichTextBox doesn't expose. If you have the HWND (Handle property) to the control, you can use the SendMessage API to send the EM_SETPARAFORMAT message to play with the formatting.

特别是 PARAFORMAT2 结构确实有一些行间距选项这可能是相关的.不过,您将不得不接触互操作.

In particular the PARAFORMAT2 structure does have some line spacing options that may be relevant. You will have to get your hands dirty with interop though.

这篇关于在 winform RichTextBox 中更改行距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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