473,326 Members | 2,815 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,326 software developers and data experts.

RichTextBox ; Autoscrolling after selection change ?

Hi,

I'm working on a RichTextBox with some "in-program" style-features
(e.g. *no way* becomes bold : like MS Word does). Got everything
working fine, flickerfree and reasonable fast, but in order to set the
style of some part of the text I use the "Selection" method (in the
case of *text* the

richTextBox1.SelectionFont.Bold = true

No problem so far, unless there are scrollbars involved. Somehow, when
I type into the RichTextBox (and after the styles are applied) the
current selection position becomes the top row; unless there is no
"scrollbar left" to scroll down to.

I've added a small sample of the code below

Expand|Select|Wrap|Line Numbers
  1.  
  2. Cursor = Cursors.WaitCursor;
  3. int origSelStart = richTextBox1.SelectionStart;
  4. int origSelLength = richTextBox1.SelectionLength;
  5.  
  6. // Freeze control
  7. SendMessage(richTextBox1.Handle, 11, 0, 0);
  8.  
  9. if (SingleLine)
  10. {
  11. // Only do the appropriate line
  12. ApplyLineStyle(Line);
  13. }
  14. else
  15. {
  16. // Apply style on all lines
  17. for (int i = 0; i < richTextBox1.Lines.GetLength(0); i++)
  18. {
  19. ApplyLineStyle(i, false);
  20. }
  21. }
  22.  
  23. // Unfreeze control
  24. SendMessage(richTextBox1.Handle, 11, 1, 0);
  25. richTextBox1.Refresh();
  26.  
  27. // Turn original selection-state back
  28. richTextBox1.SelectionStart = origSelStart;
  29. richTextBox1.SelectionLength = origSelLength;
  30.  
  31. SingleLine = false;
  32. Cursor = Cursors.Default;
  33.  
  34.  
What am I missing, is there a property or method I could use?

TIA,
Leon
Apr 11 '06 #1
1 3028
On Tue, 11 Apr 2006 13:54:17 +0200, Leon Friesema
<le***********@frostbits.nl> wrote:
Hi,

I'm working on a RichTextBox with some "in-program" style-features
(e.g. *no way* becomes bold : like MS Word does). Got everything
working fine, flickerfree and reasonable fast, but in order to set the
style of some part of the text I use the "Selection" method (in the
case of *text* the

richTextBox1.SelectionFont.Bold = true

No problem so far, unless there are scrollbars involved. Somehow, when
I type into the RichTextBox (and after the styles are applied) the
current selection position becomes the top row; unless there is no
"scrollbar left" to scroll down to.

I've added a small sample of the code below

[code]

What am I missing, is there a property or method I could use?

TIA,
Leon


Sorry, found the problem: not using SelectionStart and SelectionLength
when selecting (using the Select Method) does help

Thx anyway,
Leon
Apr 11 '06 #2

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

Similar topics

2
by: Michael A. Covington | last post by:
When you change the Font property of a RichTextBox, does it change the font of all the contents, or only the text subsequently added, or only the selection, or what?
2
by: Hariharan S | last post by:
Hi Guys, I have a string, say "Hello World" and would like to format the way I want to (say, wanna have the Hello to be bold italic and the World to be of font size 14 or so) and put it in the...
1
by: John Baro | last post by:
1) When you select the "absolute" end of a richtextbox (go to last character, hold down "shift" and click right keyboard button), the font changes to the default of the richtextbox. How can I set...
2
by: Clark Stevens | last post by:
Hi. This should be so easy, but I don't get it. Let say I have RichTextbox1 and I want to insert some text at the current insertion point, or at the beginning of selected text (if there is any). ...
1
by: Vivien Parlat | last post by:
Hello, I'm trying to create a small text editor (to be included in another project), and I've created two methods to toggle bold/italic/underlined text styles, in order to have the same...
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...
2
by: =?Utf-8?B?TWFyayBDb2xsYXJk?= | last post by:
I'm currently writing an application that has a RichTextBox and a toolbar which includes the following toolbar buttons: - Font - Font Size - Bold - Italic - Underline I want the toolbox...
0
by: TAB | last post by:
"none" <none@none.comskrev i meddelandet news:eaJIxCA7IHA.2260@TK2MSFTNGP03.phx.gbl... Use richtextbox selection properties. Like richTextBox.SelectedText or SelectedRtf if you would like to...
4
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.