richtextbox

Richtextbox Databinding issue on typing

五迷三道 提交于 2020-01-15 10:29:17
问题 After binding object to Richtextbox using bindingsource, if i type anything inside the textbox cursor will move to beginning. Can someone please help me. I am binding as below this.txtDescription.DataBindings.Add("Text", bindingWard, "Description", false, DataSourceUpdateMode.OnPropertyChanged); 回答1: Try changing the DataSourceUpdateMode to OnValidation: this.txtDescription.DataBindings.Add("Text", bindingWard, "Description", false, DataSourceUpdateMode.OnValidation); If you want to keep the

Richtextbox Databinding issue on typing

懵懂的女人 提交于 2020-01-15 10:29:06
问题 After binding object to Richtextbox using bindingsource, if i type anything inside the textbox cursor will move to beginning. Can someone please help me. I am binding as below this.txtDescription.DataBindings.Add("Text", bindingWard, "Description", false, DataSourceUpdateMode.OnPropertyChanged); 回答1: Try changing the DataSourceUpdateMode to OnValidation: this.txtDescription.DataBindings.Add("Text", bindingWard, "Description", false, DataSourceUpdateMode.OnValidation); If you want to keep the

richTextBox - add text and table

元气小坏坏 提交于 2020-01-14 14:35:12
问题 i want to add formatted text and table to a richTextBox. For this I use these codes: Text: richTextBox1.SelectionFont = new Font("Maiandra GD", 30, FontStyle.Bold); richTextBox1.SelectionColor = Color.Red; richTextBox1.SelectionIndent = 0; richTextBox1.AppendText("text text text"); And the table: StringBuilder tableRtf = new StringBuilder(); tableRtf.Append(@"{\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}"); for (int j = 0; j <5; j++) {

Clicking on a TextBlock in WPF richtextbox

故事扮演 提交于 2020-01-14 13:11:26
问题 I have a flowdocument like this: var mcFlowDoc = new FlowDocument(); var para = new Paragraph(); para.Inlines.Add(textBlock1); para.Inlines.Add(textBlock2); para.Inlines.Add(textBlock3); mcFlowDoc.Blocks.Add(para); richTextBox1.Document = mcFlowDoc; and I need an event to trigger on mouse click on a textblock: <RichTextBox Margin="10,10,230,12" Name="richTextBox1" FontFamily="Simplified Arabic" FontSize="16" IsReadOnly="True" IsReadOnlyCaretVisible="False" ForceCursor="False" FlowDirection=

RichTextBox equivalent of TextBox.AcceptsReturn

断了今生、忘了曾经 提交于 2020-01-14 07:25:13
问题 I am switching several TextBoxes out for RichTextBoxes to gain some of the cool features. I had my TextBoxes configured to AcceptReturn so that the enter key will create a new line, rather than leave the control. The RichTextBox does not seem to have this feature. Is there a simple way to do this, or do I have to capture all keypresses and handle them individually? 回答1: Note: This issue occurs only when you set the "AcceptButton" property of the form. Set the RichTextBox.AcceptsTab to true.

Prevent Blinking Cursor (IBeam) from a Read-Only RichTextBox

*爱你&永不变心* 提交于 2020-01-14 07:20:44
问题 Is there anyway to prevent the cursor (IBeam) of a read-only RichRextBox from blinking whenever the textbox got focus? I've tried to block the WM_SETFOCUS message from the WndProc but it causes the form to hang. if( m.Msg == 0x0007 ) return; 回答1: You'll need to use Win32 APIs. Here's what you could do in VB: 'API declares Private Declare Function HideCaret Lib "user32" _ (ByVal hwnd As IntPtr) As Integer Private Declare Function ShowCaret Lib "user32" _ (ByVal hwnd As IntPtr) As Integer 'hide

Prevent Blinking Cursor (IBeam) from a Read-Only RichTextBox

限于喜欢 提交于 2020-01-14 07:20:33
问题 Is there anyway to prevent the cursor (IBeam) of a read-only RichRextBox from blinking whenever the textbox got focus? I've tried to block the WM_SETFOCUS message from the WndProc but it causes the form to hang. if( m.Msg == 0x0007 ) return; 回答1: You'll need to use Win32 APIs. Here's what you could do in VB: 'API declares Private Declare Function HideCaret Lib "user32" _ (ByVal hwnd As IntPtr) As Integer Private Declare Function ShowCaret Lib "user32" _ (ByVal hwnd As IntPtr) As Integer 'hide

How to move scroll bar up by one line? (In C# RichTextBox)

穿精又带淫゛_ 提交于 2020-01-13 12:18:00
问题 For my C# RichTextBox, I want to programmatically do the same thing as clicking the up arrow at the top of a vertical scroll bar, which moves the RichTextBox display up by one line. What is the code for this? Thanks! 回答1: Here's what I do: using System.Runtime.InteropServices; [DllImport("user32.dll")] static extern int SendMessage(IntPtr hWnd, uint wMsg, UIntPtr wParam, IntPtr lParam); then call: SendMessage(myRichTextBox.Handle, (uint)0x00B6, (UIntPtr)0, (IntPtr)(-1)); Seems to work OK -

How to get displayed text from RichTextBox?

巧了我就是萌 提交于 2020-01-12 08:52:47
问题 How to get displayed text in RichTextBox? I mean if RichTextBox is scrolled to the end, I'd like to receive only those lines, which are visible for me. P.S.It'll be enough to get fisrt displayed string 回答1: You should use RichTextBox.GetCharIndexFromPosition( point ) . To get the index of the first visible character, pass new Point(0, 0) (the upper left corner of the RTB client area) as the point parameter. To get the index of the last visible character, pass new Point(rtb.ClientSize.Width,

Read-only Run elements in a WPF RichTextBox?

放肆的年华 提交于 2020-01-12 07:00:24
问题 I may be completely imagining this, but I could have sworn there was a way to make individual Run (or Parapgraph) elements in a RichTextBox read-only. I also could have sworn I tried a method for doing this out myself a few weeks ago and was satisfied with the results - I vaguely remember it looked something like this: <RichTextBox x:Name="richTextBox" AcceptsTab="True" AcceptsReturn="True" FontFamily="Courier New" FontSize="14"> <FlowDocument> <Paragraph> <Run IsReadOnly="True">I wish this