The example in this article describes how RichTextBox inserts a picture at a specified cursor position in the C # implementation WinForm. Share to everyone for your reference, specific as follows:
Gets the index position of the mouse focus in the RichTextBox control
int startposition = This.richTextBox1.SelectionStart;
Select a few characters starting from the mouse focus
this.richTextBox1.SelectionLe
In the online did not find the right code, wrote a paragraph, still needs to be optimized ...Directly on the code/// ///Scroll to an item/// /// Private voidScrollitem (Block sparent) {intCount = RichTextBox1.Document.ContentStart.GetOffsetToPosition (richTextBox1.Document.ContentEnd);//get the height of the text in the entire textbox intS1 = richTextBox1.Document.ContentStart.GetOffsetToPosition (sparent. Contentend);//The height of the entry block to the begi
Suppose the RichTextBox1 text is "Hello, I Love you China" and want to turn China into red, thenCan be found first in the position is 7; the position of the country is 8Set richtextbox1.selectionstart=7; RichTextBox1.rich.SelectionLength = 8;Then set the text color of this paragraphRich. SelectionBackColor = Color.fromname ("Red"); The Color.fromname () method converts a string to the corresponding color property, which is very convenientRich. Focus (); Finally get focus (if you need to do a lat
Public Sub HighLight () Sub HighLight (RTB As RichTextBox, lColor As Long)
'Add new color to color table
'Add tags \ highlight # and \ highlight0
'Where # is new color number
Dim iPos As Long
Dim strRTF As String
Dim bkColor As Integer
With RTB
IPos =. SelStart
'Bracket selection
. SelText = Chr ( H9D) . SelText Chr ( H81)
StrRTF = RTB. TextRTF
'Add new color
BkColor = AddColorToTable (strRTF, lColor)
'Add highlighting
StrRTF = Replace (strRTF, "\ '
Using system;using system.collections.generic;using system.drawing;using system.windows.forms;using System.IO; namespace test{///Example of using RichTextBox in C # to achieve picture-and-text blending and preservation
It's really simple, as long as you set the attached property focusmanager.isfocusscope in the container control to True .The following is a simple use case:"Wpfapplication1.mainwindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="Http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow"height=" -"Width="525"> " -"/> "*"/> "0"orientation="Horizontal"Focusmanager.isfocusscope="True"> " -"> 123" -"> "1"/> The following is a runabout how to keep highlighting selecte
The company's system has a new requirement. It is very simple, that is, the colors and fonts of signatures, dates, and texts should be different when the document is presented. This is a simple requirement. However, in practice, it took me a while, isn't it a bit difficult to think about? It is a small deviation.
The RichTextBox Control is required for this function, so I wrote a method for adding text to make it simple:
Code highlighting produced by
1. Get the current scroll bar position// gets the current scroll bar position Richtextbox.verticaloffset;richtextbox.horizontaloffset;// gets the current cursor position richtextbox.caretposition2. Scroll to start, end, specify position // //Summary://sets the view of the edit control to the end of the content. Public voidScrolltoend (); // //Summary://The view of the edit control to the beginning of the viewport. Public voidScrolltohome (); // //Sum
I originally planned to use the word Ole editing function, but I don't know what's going on. The word's RTF editing inserts an image, and the image displayed in RichTextBox is rather vague. I have to change it myself.
The exrichtextdemo on codeproject adds the image and text insertion method.
Google hasn't found any control that can set the RTF spacing for a long time.
The spacing settings and printing are added on the basis of exrichtextbox. Curre
Today, I made a prompt and needed to control the line spacing of text display. I originally wanted to use label for it. Later I found that there are no relevant properties to set. I searched the internet for it, the only method seems to be to control the re-painting by yourself, so I didn't want to use such troublesome processing. So I tried another control RichTextBox and found that there was still no attribute that could be directly set, however, it
Reference: http://blog.iordanov.info /? P = 32
To implement the drag-and-drop function of RichTextBox, you only need to set enableautodragdrop = true to automatically implement it, which is very simple. However, it is a little complicated to implement some personalized control.
What I need to implement is: If you drag and drop a file in, you do not want to embed an object connection by default, but upload the file. In other cases, you just want to
Properties-all sizes are in twipsXLeft-Position of the left edge of the tableIsCentered-Set to True to center the tableRows-Sets or returns the number of rows in the tableColumns-Sets or returns the number of columns in the tableRow-An Array of Rows (1 to Rows)Column-An Array of columns (1 to Columns)Column (I). xWidth-Width of the ith columnCell-A 2-d Array of Cells (1 to Rows, 1 to Columns)Cell (r, c). Contents-Sets or returns the contents of the cell
MethodsInsertTable (RTB As
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
///
///
Set the text burst in the selected part of the RichTextBox Control
///
Private
Void
Setrtbtextproperty (){
//
Select text, and select from the text control from the first character to the last character.
Rtbshow. Select (
2
,
2
);
//
Set the font of selected text
Rtbshow. selectionfo
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.