473,503 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RichTextBox - placing caret at end of Text

Udi
Hi,
I have derived my ConsoleTextBox from RichTextBox.
I'm trying to implement a console-like text box with history
capabilities.
My problem is that when I'm trying to append a command, I can't place
the cursor at the end of the text.

### See code below - problem in SetCmdLn() ####

My questions are:
1. How do I place the caret at the end of my new text?
2. why the Length of Text retrieves the
length without the length of the added line?
3. Is there a way to update only a speciffic
line in Lines (in my case its always the last line) without having
to copy all the Lines to a new array of strings?
Thanks a lot!
Udi.




protected override bool IsInputKey(Keys keyData)
{
int lineNo = GetLineFromCharIndex(SelectionStart);
switch (keyData)
{
case Keys.Enter:
{
:
}
case Keys.Up:
{ //user asks for previous history cmd
if (lineNo == Lines.Length - 1)
{
OnArrowUp();
return true;
}
break;
}
case Keys.Down:
{//user asks for next history cmd
:
}
:
}

return base.IsInputKey(keyData);
}
private void OnArrowUp()
{
// Point to previous history cmd while possible
:
SetCmdLn();
}
private void SetCmdLn()
{
string [] tmpTxtMatrix = new string [Lines.Length];
Lines.CopyTo(tmpTxtMatrix, 0);

//Replace last line in console with history value
tmpTxtMatrix[tmpTxtMatrix.Length - 1] = history[historyIdx] as
string;
//Clear();
Lines = tmpTxtMatrix;
//String.Join("\n", tmpTxtMatrix);
//AppendText( String.Join("\n", tmpTxtMatrix));
Select(Text.Length ,0); ######## THIS DOES NOT WORK !!!
########
}
It always sets the caret position BEFORE the last added line.
(As you can see in the commented out lines, I tried manipulating it but

it didn't help.)

Apr 19 '06 #1
0 1575

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
9422
by: S.W. Rasmussen | last post by:
A trivial (?) question: does anyone know how to change the shape of the cursor in a RichTextBox control from the normal vertical line to an underscore?
0
1079
by: Sean | last post by:
Hi, I have an application that will pop up a listboxwindow (containing words that users can choose from) when I type certain characters on a richtextbox. Now I have a problem of maintaining...
2
7500
by: Joseph Lee | last post by:
Hi, I am trying to find the command to scroll the richtextbox to the latest appended string at the bottom. I have tried update, refresh and scroll to caret but it does not seem to work Thanks...
6
29139
by: Rachel Suddeth | last post by:
I have the index of a line in the Lines array of a RichTextBox. I would like to have it scroll so that line displays at the top. Is there no way to do this? The only way I can see to make it...
1
293
by: Peter | last post by:
Hi. I have RichTextBox. There is some text. For example cursor is in the middle of that text. And now I would like to add some new text on the position of cursor. Somethink like when I press...
8
2157
by: Dennis | last post by:
How can I tell if the Insert Mode is on or off? -- Dennis in Houston
1
3385
by: Udi | last post by:
Hi, I have derived my ConsoleTextBox from RichTextBox. I'm trying to implement a console-like text box with history capabilities. My problem is that when I'm trying to append a command, I can't...
8
2575
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have created a Control that extends RichTextBox to do syntax-hilighting. My strategy is to have a timer that restarts every time a user types a key so that it can wait until the user pauses for...
4
13400
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I have a multiline RichTextBox that I use for data logging. I'm concerned about how the AppendText method reacts when over time the maximum number of characters have been added. Do the...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.