473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

TextCursor in RichTextBox

When you give focus to a RichTextBox, then it goes to the textCursor, but i
don't want to give the richtextbox focus, cause there is being written a lot
in it, and I have to do something else at the same time, then if I don't
give it focus, and I add some text to it, then it don't automaticly scrolls
down to the textcursor, is there a way to make the RichTextBox scroll down
to the textcursor, without giving it focus??

Richard
Nov 20 '05 #1
7 2022
use the scrolltocaret method

"Richard" <s@b.k> wrote in message
news:uy**************@TK2MSFTNGP12.phx.gbl...
When you give focus to a RichTextBox, then it goes to the textCursor, but
i
don't want to give the richtextbox focus, cause there is being written a
lot
in it, and I have to do something else at the same time, then if I don't
give it focus, and I add some text to it, then it don't automaticly
scrolls
down to the textcursor, is there a way to make the RichTextBox scroll down
to the textcursor, without giving it focus??

Richard

Nov 20 '05 #2

"Jared" <VB***********@email.com> skrev i en meddelelse
news:10*************@corp.supernews.com...
use the scrolltocaret method


It doesn't help, if it doesn't have focus, then it won't scroll down,

Richard
Nov 20 '05 #3
Richard, I don't think that is true
Add a new form
1 place a textbox, a button and a richtextbox on the form and add the
following code.
Now, examine the output window.

My Output:
Got Focus

'My button control was pressed

Lost Focus

Got Focus

'Reset the focus to the textbox to make a point

Line Number 1

Line Number 2

Line Number 3

Line Number 4

Line Number 5

'Occurred when I incpected the output window and moved focus to the DevEnv

Lost Focus
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Me.TextBox1.Focus()

For counter As Integer = 1 To 5

Me.RichTextBox1.AppendText("Line Number " & counter & vbCrLf)

Console.WriteLine("Line Number " & counter)

Me.RichTextBox1.ScrollToCaret()

Next

End Sub

Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.LostFocus

Console.WriteLine("Lost Focus")

End Sub

Private Sub Textbox1_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.GotFocus

Console.WriteLine("Got Focus")

End Sub
"Richard" <s@b.k> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

"Jared" <VB***********@email.com> skrev i en meddelelse
news:10*************@corp.supernews.com...
use the scrolltocaret method


It doesn't help, if it doesn't have focus, then it won't scroll down,

Richard

Nov 20 '05 #4
* "Richard" <s@b.k> scripsit:
When you give focus to a RichTextBox, then it goes to the textCursor, but i
don't want to give the richtextbox focus, cause there is being written a lot
in it, and I have to do something else at the same time, then if I don't
give it focus, and I add some text to it, then it don't automaticly scrolls
down to the textcursor, is there a way to make the RichTextBox scroll down
to the textcursor, without giving it focus??


If you want to scroll to the end of the text:

From my FAQ:

When using a RichTextBox control for displaying logging information, it is
useful to scroll the recently added line into view. There are two ways to
accomplish this:

\\\
Private Const WM_VSCROLL As Int32 = &H115
Private Const SB_BOTTOM As Int32 = 7

Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32 _
) As Int32

Private Sub AddLine(ByVal Destination As RichTextBox, ByVal Text As String)
With Destination
.AppendText(Text & ControlChars.NewLine)
SendMessage(Destination.Handle, WM_VSCROLL, SB_BOTTOM, 0)
End With
End Sub
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5
Thank you SO much, that was just what I was searching for.

QUOTE: "From my FAQ:"

Where Can I find your FAQ??
Yet again, thank you for the help.

Richard
Nov 20 '05 #6
* "Richard" <s@b.k> scripsit:
Thank you SO much, that was just what I was searching for.

QUOTE: "From my FAQ:"

Where Can I find your FAQ??


<URL:http://dotnet.mvps.org/dotnet/faqs/>

Notice that the index of the FAQ is currently in German, the articles
linked by the index are written in English :-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #7
> Notice that the index of the FAQ is currently in German, the articles
linked by the index are written in English :-).


ok, that's not the easiest to read (The german headlines), but thanks
anyway,
Nov 20 '05 #8

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

Similar topics

0
by: nouno | last post by:
I am trying to spell check a richtextbox. Through code (shown below) I save the contents of the richtextbox to a rtf file, open the rtf file in Word, spell check it, save it, and then load the ftf...
3
by: kangoo | last post by:
Hi, I'm trying to remove the last charater in a richTextBox. I though richTextBox.Text.Remove(richTextBox.Text.length-1, 1); would work, but it does nothing (eg richTextBox.Text += "some new...
12
by: M O J O | last post by:
Hi, If I inside a thread creates a RichTextBox and only use this inside the thread, will there be any thread problems? I need to convert between Text and RTF inside a thread. Thanks!! M...
2
by: JonnyT | last post by:
I searched high and low for an answer on how to auto scroll a richtextbox and now I finally have it. Since it took me a while to get a good efficient way of doing it that didn't require focus to...
0
by: Vincent | last post by:
Dear all, I have implemented a class to export the content of RichTextBox to image in WYSISYG mode so that line breaks on the screen are the same as exported. C# Code: public struct...
9
by: James Wong | last post by:
Hi, I use the RichTextBox in my program. It will use different language in this RichTextBox (chinese and english characters), and it set the "DualFont" and use different fonts. By the way, how...
3
by: michael sorens | last post by:
The documentation for the RichTextBox is sketchy at best. I want to do a very simple task but I cannot find information on this. I am using a RichTextBox as an output window. Some text I want to...
0
by: Vimalathithan | last post by:
I just developing a editor. I have provide the options like Bold, Italic, underlin, font change, font size change. These font options are keep in with one toolstripbutton. the toolstripbar keep...
1
by: bmerlover | last post by:
I'm having trouble reading quotations inside the richTextBox when a file is opened on to it. I've tried a couple different methods, most of them didn't compile. I came across one that does compile...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.