在文本框或 Richtextbox 中显示空白
Visual Studio 中有一个选项(从我记事起)可以让您在代码中看到“空白”。这也经常出现在文件差异查看器中。
我想知道是否有人知道如何在 VB.net(或任何其他方式)中完成此操作,以便我可以在我的软件中使用类似类型的显示选项。
我还没有尝试这样做,但我唯一的第一个想法是覆盖文本框的“绘制”,以通过 GDI 手动添加小选项卡“箭头”和空格“点”,或者从头开始创建一个 texbox 控件。在我看来,可能有一种更简单的方法可以做到这一点。
欢迎任何建议或解决方案。
There is an option in Visual Studio (since as far back as I can remember) that allows you to see "Whitespace" in your code. This is often seen in file differential viewers as well.
I'm wondering if anyone knows how this can be accomplished in VB.net (or any other way) so that i could use a similar type of display option in my software.
I have not yet tried to do this but my only first thoughts would be to override the "paint" of the textbox to actually add the little tab "arrows" and space "dots" manually via GDI, or create a texbox control from scratch. Seems to me there could be an easier way to do this.
Any suggestions or solutions are welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在整个文档中搜索 vbTab 常量并将其替换为小箭头(
→
)(用灰色或您想要的任何东西绘制)对空格字符执行相同的操作,但将其替换为灰点 (
·
)如果您想将其改回来,请
在完成后将
·
替换为空格,并将箭头 (→
) 替换为制表符,然后设置一个布尔值 (useSymbol) 为 true 并在文本框的 keydown 事件中使用此布尔值来检查是否应该打印常规空格/制表符或
·
/→
Search for the vbTab constant in the entirety of the document and replace them with a small arrow (
→
)(drawn with grey or whatev. you want)Do the same for the space char but replace it with a grey dot (
·
)if you want to change it back, replace
·
with spaces and replace the arrows (→
) with tabsafter this is done set a boolean (
useSymbol
) to true and use this boolean in the keydown event of the textbox to check whether you should print regular spaces/tabs or·
/→