Richtextbox.text覆盖VB.NET WPF中的属性 [英] Richtextbox.text override property in VB.NET WPF

查看:103
本文介绍了Richtextbox.text覆盖VB.NET WPF中的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是VB.net的新手。我想使用Richtextbox.Text。但是,显示Text不是Richtextbox的一部分的错误。在进一步检查后,我可以看到它可以使用Overrides Property Text As String从链接覆盖

RichTextBox.Text属性(System.Windows.Forms) [ ^ ]



我想知道如何将它添加到项目或课程中。请帮忙。谢谢。



我尝试过:



什么都没有用。尝试使用Textrange而不是

I am new to VB.net. I want to use Richtextbox.Text. However, the error showing that Text is not part of Richtextbox. Upon checking further, I can see that it can be overridden using Overrides Property Text As String from the link
RichTextBox.Text Property (System.Windows.Forms)[^]

I would like to know how to add it to project or class. Please help. Thank you.

What I have tried:

Nothing has worked. Tried using Textrange and not working

推荐答案

正如Bernhard在评论中提到的那样,您正在查看Windows窗体控件的文档。您需要查看WPF控件的文档,该控件没有 Text 属性:



RichTextBox类(System.Windows.Controls)| Microsoft Docs [ ^ ]



要获取或设置文本,您可以使用此StackOverflow答案 [ ^ ] :

As Bernhard mentioned in the comments, you're looking at the documentation for the Windows Forms control. You need to look at the documentation for the WPF control, which doesn't have a Text property:

RichTextBox Class (System.Windows.Controls) | Microsoft Docs[^]

To get or set the text, you can use the code from this StackOverflow answer[^]:
' Set the text:
richTextBox1.Document.Blocks.Clear()
richTextBox1.Document.Blocks.Add(new Paragraph(new Run("The text...")))

' Read the text:
Dim text As String = New TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd).Text



如何:从中提取文本内容RichTextBox | Microsoft Docs [ ^ ]

如何:保存,加载和打印RichTextBox内容Microsoft Docs [ ^ ]


这篇关于Richtextbox.text覆盖VB.NET WPF中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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