Place a cursor on given line-character in C sharp
How can we programmatically place a cursor on the given line or on the character in a RichTextBox control in the C#?
Expert
RichTextBox control has Lines array property that demonstrates one item of the array in separate line. Every line entry has a Length property that can be used to exactly position the cursor at the character, which is shown in the following code:
private void GoToLineAndColumn(RichTextBox RTB, int Line, int Column)
{
int offset = 0;
for(int i = 0; i < Line -1 && i < RTB.Lines.Length; i++)
offset += RTB.Lines[i].Length + 1;
}
RTB.Focus();
RTB.Select(offset + Column, 0);
What is .NET Framework? Specify its applications?
What is Custom Activities?
Illustrate the difference between System.Windows.dll and System.Windows.Browser.dll?
Explain Common Type System (CTS)?
Explain about the types of ASP Objects?
Explain what would you do to get rid of Microsoft visual basic name space?
Explain concept of the Destructor?
Why there is a requirement of user-defined controls?
Whether XCOPY copies the system files and the hidden files or not.
Is it a good practice to practise handle the exceptions in code?
18,76,764
1933820 Asked
3,689
Active Tutors
1432287
Questions Answered
Start Excelling in your courses, Ask an Expert and get answers for your homework and assignments!!