What are tags?
RichTextBox - autoscrolling
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What is interesting here?
• Duels
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Register!

QAIX > .Net Development > RichTextBox - autoscrolling 11 May 2009 20:40:37

  Top users: 
  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Модератор:

RichTextBox - autoscrolling

Vince P 8 March 2006 10:55:47
 C#2.0
I'm sure this was asked before but I wasn't able to find anything.

--- How to automatically scroll through the text in a RichTextBox when the lines of text go beyond the lower border of the control (like when adding new lines of text in a "status window" type operation)

I know I can set SelectionStart to the end, or ScrollToCaret but these methods/properties require the RichTextBox have the focus.

In this case, my richtextbox is read-only, so the user would never normally put the focus in there, plus the operation that is putting the new lines of text in there takes many minutes to run, so it's not acceptable to keep the focus in there anyway.

I tried this

richTrace.Text = richTrace.Text + addText + Environment.NewLine­;

// richTrace.Focus();



richTrace.Selection­Start = richTrace.TextLengt­h - 1;



When richTrace.Focus() is not commented out, the form steals the focus from whatever other form the user might in at that moment.

When it's commented out, the lines of text get appened into the RichTextBox but the text is not scrolled.

Is there a solution to this?

-------------------­-
"All left-wing parties in the highly industrialised countries are at bottom a sham" - George Orwell "Rudyard Kipling" (1942)


Add comment
Vince P 8 March 2006 11:00:53 permanent link ]
 Well for the time being if the user happens to have the form in question as the app's active form then I'm going to set the focus in that RichTextBox.. But otherwise I wont.

I don’t think many of my users position the windows in such a way where if the window was in the background they would arrange it so that they can see the progress of the output.

So I settle on this:

if (Form.ActiveForm == this)
{

richTrace.Focus();
try
{
richTrace.Selection­Start = richTrace.TextLengt­h - 1;
}
catch { }
}


-----Original Message-----> From: Discussion forum for developers using Windows Forms to > build apps and controls > [mailto:D­OTNET-WINFORMS@DISCUSS.DEVELOP.COM] On Behalf Of Vince P> Sent: Wednesday, March 08, 2006 12:56 AM> To: DOTNET-WINFORMS@DIS­CUSS.DEVELOP.COM> Subject: [DOTNET-WINFORMS] RichTextBox - autoscrolling>
C#2.0> I'm sure this was asked before but I wasn't able to find anything.>
--- How to automatically scroll through the text in a > RichTextBox when the lines of text go beyond the lower > border of the control (like when adding new lines of text in > a "status window" type operation)>
I know I can set SelectionStart to the end, or ScrollToCaret > but these methods/properties require the RichTextBox have the focus.>
In this case, my richtextbox is read-only, so the user would > never normally put the focus in there, plus the operation > that is putting the new lines of text in there takes many > minutes to run, so it's not acceptable to keep the focus in > there anyway.>
I tried this>
richTrace.Text = richTrace.Text + addText + Environment.NewLine­;>
// richTrace.Focus();>­
richTrace.Selection­Start = richTrace.TextLengt­h - 1;>
When richTrace.Focus() is not commented out, the form steals > the focus from whatever other form the user might in at that moment. >
When it's commented out, the lines of text get appened into > the RichTextBox but the text is not scrolled.>
Is there a solution to this?>
-------------------­-> "All left-wing parties in the highly industrialised countries > are at bottom a sham" - George Orwell "Rudyard Kipling" (1942)>

Add comment
Peter Ritchie 8 March 2006 19:05:29 permanent link ]
 I haven't tried it specifically with RichTextBox; but, you might want to
have a look at the RichTextBox.AutoScr­ollOffset member and the
ScrollControlIntoVi­ew method (not to mention the AutoScroll property).

I'd have to play around with these in the context of RichTextBox to offer
any guidance on how it differs from other controls.

If it works for you, I'd be interested in the results.

http://www.peterRit­chie.com/Blog/

On Wed, 8 Mar 2006 00:55:47 -0600, Vince P <vincep1974@COMCAST­.NET> wrote:
C#2.0>I'm sure this was asked before but I wasn't able to find anything.>
--- How to automatically scroll through the text in a RichTextBox when
the lines of text go beyond the lower border of the control (like when
adding new lines of text in a "status window" type operation)>
I know I can set SelectionStart to the end, or ScrollToCaret but these
methods/properties require the RichTextBox have the focus.>
In this case, my richtextbox is read-only, so the user would never
normally put the focus in there, plus the operation that is putting the
new lines of text in there takes many minutes to run, so it's not
acceptable to keep the focus in there anyway.>
I tried this>
richTrace.Text = richTrace.Text + addText + Environment.NewLine­;>
// richTrace.Focus();>­
richTrace.Selectio­nStart = richTrace.TextLengt­h - 1;>
When richTrace.Focus() is not commented out, the form steals the focus
from whatever other form the user might in at that moment.>
When it's commented out, the lines of text get appened into the
RichTextBox but the text is not scrolled.>
Is there a solution to this?

Add comment
Vince P 8 March 2006 23:29:33 permanent link ]
 Ok based on your advise, I did try AutoScrollOffset. That method wants the
location (System.Drawing.Poi­nt) of where to scroll to. I don't know how to
get the size of the entire text area (which would include the size of the
control + the size of the hidden text portion).

AutoScroll isn't a proprty of RTB. ScrollControlIntoVi­ew isn't a method of
RTB.

Since the solution to this isn't so obvious, I rather not spend all this
time trying to solve it, having other priorties.

-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps and
controls [mailto:D­OTNET-WINFORMS@DISCUSS.DEVELOP.COM] On Behalf Of Peter
Ritchie
Sent: Wednesday, March 08, 2006 9:05 AM
To: DOTNET-WINFORMS@DIS­CUSS.DEVELOP.COM
Subject: Re: [DOTNET-WINFORMS] RichTextBox - autoscrolling

I haven't tried it specifically with RichTextBox; but, you might want to
have a look at the RichTextBox.AutoScr­ollOffset member and the
ScrollControlIntoVi­ew method (not to mention the AutoScroll property).

I'd have to play around with these in the context of RichTextBox to offer
any guidance on how it differs from other controls.

If it works for you, I'd be interested in the results.

http://www.peterRit­chie.com/Blog/

On Wed, 8 Mar 2006 00:55:47 -0600, Vince P <vincep1974@COMCAST­.NET> wrote:
C#2.0>I'm sure this was asked before but I wasn't able to find anything.>
--- How to automatically scroll through the text in a RichTextBox when
the lines of text go beyond the lower border of the control (like when
adding new lines of text in a "status window" type operation)>
I know I can set SelectionStart to the end, or ScrollToCaret but these
methods/properties require the RichTextBox have the focus.>
In this case, my richtextbox is read-only, so the user would never
normally put the focus in there, plus the operation that is putting the new
lines of text in there takes many minutes to run, so it's not acceptable to
keep the focus in there anyway.>
I tried this>
richTrace.Text = richTrace.Text + addText + Environment.NewLine­;>
// richTrace.Focus();>­
richTrace.Selectio­nStart = richTrace.TextLengt­h - 1;>
When richTrace.Focus() is not commented out, the form steals the focus
from whatever other form the user might in at that moment.>
When it's commented out, the lines of text get appened into the
RichTextBox but the text is not scrolled.>
Is there a solution to this?

Add comment
Peter Ritchie 8 March 2006 23:34:46 permanent link ]
 Sorry, I should have mentioned ScrollControlIntoVi­ew and AutoScroll are
members of the Form class used in a child/parent relationship, I suppose.
Yes, it's unclear what you're supposed to use for a Point to
AutoScrollOffset.

On Wed, 8 Mar 2006 13:29:33 -0600, Vince P <vincep1974@COMCAST­.NET> wrote:
Ok based on your advise, I did try AutoScrollOffset. That method wants
location (System.Drawing.Poi­nt) of where to scroll to. I don't know how
get the size of the entire text area (which would include the size of the>control + the size of the hidden text portion).>
AutoScroll isn't a proprty of RTB. ScrollControlIntoVi­ew isn't a method
RTB.>
Since the solution to this isn't so obvious, I rather not spend all this>time trying to solve it, having other priorties.>
-----Original Message----->From: Discussion forum for developers using Windows Forms to build apps
controls [mailto:D­OTNET-WINFORMS@DISCUSS.DEVELOP.COM] On Behalf Of Peter>Ritchie>Sent:­ Wednesday, March 08, 2006 9:05 AM>To: DOTNET-WINFORMS@DIS­CUSS.DEVELOP.COM>Sub­ject: Re: [DOTNET-WINFORMS] RichTextBox - autoscrolling>
I haven't tried it specifically with RichTextBox; but, you might want to>have a look at the RichTextBox.AutoScr­ollOffset member and the>ScrollControlIn­toView method (not to mention the AutoScroll property).>
I'd have to play around with these in the context of RichTextBox to offer>any guidance on how it differs from other controls.>
If it works for you, I'd be interested in the results.>
On Wed, 8 Mar 2006 00:55:47 -0600, Vince P <vincep1974@COMCAST­.NET> wrote:>
C#2.0>>I'm sure this was asked before but I wasn't able to find anything.>>
--- How to automatically scroll through the text in a RichTextBox when>the lines of text go beyond the lower border of the control (like when>adding new lines of text in a "status window" type operation)>>
I know I can set SelectionStart to the end, or ScrollToCaret but these>methods/prope­rties require the RichTextBox have the focus.>>
In this case, my richtextbox is read-only, so the user would never>normally put the focus in there, plus the operation that is putting the
lines of text in there takes many minutes to run, so it's not acceptable
keep the focus in there anyway.>>
I tried this>>
richTrace.Text = richTrace.Text + addText + Environment.NewLine­;>>
// richTrace.Focus();>­>
richTrace.Selecti­onStart = richTrace.TextLengt­h - 1;>>
When richTrace.Focus() is not commented out, the form steals the focus>from whatever other form the user might in at that moment.>>
When it's commented out, the lines of text get appened into the>RichTextBox but the text is not scrolled.>>
Is there a solution to this?

Add comment
Guest 16 September 2008 16:20:13 permanent link ]
 Try to use ScrollToCarret() method.
Add comment
Guest 11 May 2009 20:40:37 permanent link ]
 I made a blog post that explains a method of getting rid of all the focus problems. It wraps it all up neatly in a small class too.

<a href="http://bitmat­ic.com/csharp/implem­enting-a-scrolling-r­ichtextbox">Implemen­ting a scrolling Richtextbox</a>
Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или законы РФ. Ваш ip-адрес записывается.


QAIX > .Net Development > RichTextBox - autoscrolling 11 May 2009 20:40:37

see also:
AW: build setup for a new project
German Usergroup Mailing List
Reminder, 3.2 branch coming this…
pass tests:
What is Your Temperament?
see also:
wholesale burberry t shirt afficiton…
replica louis vuitton clothing burberry…

  Copyright © 2001—2010 QAIX
Идея: Монашёв Михаил.
Авторами текстов, изображений и видео, размещённых на этой странице, являются пользователи сайта.
See Help and FAQ in the community support.qaix.com.
Write in the community about the bugs you have noticedbugs.qaix.com.
Write your offers and comments in the communities suggest.qaix.com.
Information for parents.
Пишите нам на .
If you would like to report an abuse of our service, such as a spam message, please .
Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .