RichTextBox控件使您可以显示或编辑RTF(RTF格式)内容。此内容可能包括格式化的段落,超链接和内嵌图像。
TextField 中的富文本并获取 RenderParagraph
我知道 TextField 主要用于纯文本,但我已经看到可以在内部显示格式丰富的文本。我是 Flutter 的初学者,不太明白什么是
所以我想做代码编辑器来输入代码,我使用RichTextBox,但我不知道如何从中获取文本,我想使用MVVM模式,我尝试使用事件(但我不知道它是否正确) ), 所以我想做代码编辑器来输入代码,我使用RichTextBox,但我不知道如何从中获取文本,我想使用MVVM模式,我尝试使用事件(但我不知道它是否正确), <RichTextBox x:Name="CodeField" AcceptsTab="True" Margin="0,51,0,22" RenderTransformOrigin="0.5,0.5" Grid.ColumnSpan="3" TextChanged="CodeField_TextChanged" > <RichTextBox.Resources> <Style TargetType="{x:Type Paragraph}"> <Setter Property="Margin" Value="0"/> </Style> </RichTextBox.Resources> </RichTextBox> public string GetSetCode { get { return codetext; } set { codetext = value; OnPropertyChanged(nameof(codetext)); } } private void CodeField_TextChanged(object sender, TextChangedEventArgs e) { TextRange textRange = new TextRange( // TextPointer to the start of content in the RichTextBox. CodeField.Document.ContentStart, // TextPointer to the end of content in the RichTextBox. CodeField.Document.ContentEnd ); viewModel.GetSetCode= textRange.Text; MessageBox.Show(viewModel.codetext); } MessageBox.Show(viewModel.codetext); MessageBox 显示数据,但是当我尝试这样做时 viewModel.GetSetCode= textRange.Text; 字段代码文本 = null; 所以答案很简单,可用的必须是静态的MainWindow.xaml.cs public partial class MainWindow : Window { MainViewModel viewModel; public MainWindow() { InitializeComponent(); viewModel = new MainViewModel(); } private void CodeField_TextChanged(object sender, TextChangedEventArgs e) { TextRange textRange = new TextRange( // TextPointer to the start of content in the RichTextBox. CodeField.Document.ContentStart, // TextPointer to the end of content in the RichTextBox. CodeField.Document.ContentEnd ); // The Text property on a TextRange object returns a string // representing the plain text content of the TextRange. viewModel.SetText = textRange.Text; } } ViewModel.cs class MainViewModel : INotifyPropertyChanged { private static string codetext; public string GetText { get { return codetext; } } public string SetText { set { codetext = value; } } private LanguageForAPI selectedLanguage; public MainViewModel() { CompiledCommand = new RelayCommand(CallRequest, true); } private void CallRequest() { Request request = new Request ( lang: SelectedLanguageForAPI.GetArgument, source: GetText, input: "", memory_limit: 262144, time_limit: 5, context: "", callback: "" ); MessageBox.Show(GetText); } }
我需要获取 WPF .NET 6 RichTextBox 末尾的光标位置,以便选择和更改每个附加行的字体
在我的应用程序中,我有一个带有只读 RichTextBox 的简单窗口。我正在使用 WPF、.NET 6。窗口的目的只是显示
我写了一个真空管交叉参考程序。 我不知道如何迭代 RichTextBox1 以使请求的管值变为粗体。 搜索 6AU8A 时的现有输出 管
我正在使用可以包含图像的RichTextBox。我使用 OpenFileDialog 导入它们,然后放入 InlineUIContainer 中。 显示出来了,xaml代码如下。 ...
我有一个富文本框,我想在上面使用超链接,所以当用户点击它时,网站链接或本地文件被打开。在我的最后一个问题中,我说链接点击事件不会触发道具......
我想在 RichTextBox 中保护一些选定的文本。我试过这样的事情: 鼠标点击事件(...) { 如果(e.Button == MouseButtons.Middle) { 选择保护=真; } } ...
我正在开发 RichTextBox 和几个按钮的测试应用程序。该控件包含文本,每当我单击按钮时位于插入符号位置,我想计算接下来的 3 个单词...
我正在创建一个扫描 Word 文档的 WinForms,提取重要数据并将其写入 rtf 格式的富文本框。我想创建一个按钮来复制丰富的文本框内容,这样我们...
在 RichTextBox 中显示 .oft 模板的 HTMLBody
我正在尝试创建一个简单的表单,仅在 Visual Studio 2019 的 RichTextBox 中显示 Outlook 模板 HTML 正文的 HTML 内容。到目前为止,我能够按预期使用该模板,但是......
RichTextBox 在调整大小时不滚动属性并显示额外的空白
RichTextBox 控件似乎有这个奇怪的错误,我正试图找到解决它的方法。 假设您有一个 RichTextBox 控件,其中包含足够的文本来显示垂直滚动条。那么,你
如何将 RichTextBox 中的文本/内容保存/选择到 .xlsx 文件
我目前正在研究一个解决方案,要求我将 RichTextBox 的内容保存到 .xlsx 文件,我正在尝试的代码(见下文)似乎没有选择 RichTextBox 的内容。 是
我正在选择 richtextbox1 中的特定文本部分并使用正则表达式替换它。替换文本后,我的选择消失了。即使在替换后我也想保持相同的选择。因为我...
我正在为我们的用例调查最佳富文本编辑器 (RTE) 组件。 要求是: 在 React 中实现,不需要 RWD 基本功能,如粗体、斜体、对齐、...
我有一个带有 RichTextBox 的 WinForm。 我正在尝试在给定的行和列中写入 RichTextBox: 这是代码: 公共 Form1() { 初始化组件(); richTextBox1 = ...
有什么方法可以让我在WPF中把富文本框的内容转换为位图?我尝试了下面帖子中提到的解决方案。Save RichTextBox FlowDocument to image But my dilemma is I ...
RichTextBox在C#中的Word Wraps中使用非常长的文本行并关闭Word Wrapping。
我想让RichTextBox停止包裹长行文本。这些长长的文本行可能非常长,有时长达数百万个字符。这些都是HL7中的嵌入式PDF文件,可以 ...
我在一个WPF RichTextBox中使用TextRanges,我想改变一个TextRange的字体颜色,但如果在它旁边写上文字,它有原来的颜色。例如,我有一个 ...
我在一个WPF RichTextBox中使用TextRanges,我想改变一个TextRange的字体颜色,但如果在它旁边写上文字,它就有原来的颜色。例如,我有一个 ...