473,378 Members | 1,391 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,378 software developers and data experts.

Perpetual Scrolling Window

Hi all,

Is it possible to do a console like scrolling window in a Windows Form app?

The closest I've gotten is to use a RichTextBox and append text to it.

However, after a while, there is too much text, I need to clear the textbox
- this causes the screen to flash and I lose all prior text.

Is there a good method of keeping only X lines in a RichTextBox?

Logs could be coming in quickly ... so are there any high performance
methods of doing this?

Jun 7 '07 #1
5 1456

"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
Hi all,

Is it possible to do a console like scrolling window in a Windows Form
app?

The closest I've gotten is to use a RichTextBox and append text to it.

However, after a while, there is too much text, I need to clear the
textbox
- this causes the screen to flash and I lose all prior text.

Is there a good method of keeping only X lines in a RichTextBox?

Logs could be coming in quickly ... so are there any high performance
methods of doing this?
This might be overkill but I have used a virtual list ListView control to do
somewhat the same. If you have a data store of anykind that can feed t he
ListView you can then set the ListView to virtual and set the count to the
number of items in your data store. At that point the listview will start
firing (sorry not close to VS) an event asking you to provide a
ListViewItem. In this routine (think of it as the binding routine) you get
the item number which in most cases would be an index into your data store.
You can sort this by sorting your data store and then reseting the count.
There are other events to handle selections but in most cases you won't need
to deal with them. When you handle an item click in the ListView you again
get the index so you should have a helper function to get the item from the
data store.

Hope this gets you started. I have an app that loads about 25K items into
10 virtual listboxs on app startup. Items are serialized objects and the
app takes about 1-2 secs to load all the data. Before I used virtual
ListView it took about 10-15 seconds.

Lloyd Sheen

Jun 7 '07 #2

"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
Hi all,

Is it possible to do a console like scrolling window in a Windows Form
app?

The closest I've gotten is to use a RichTextBox and append text to it.

However, after a while, there is too much text, I need to clear the
textbox
- this causes the screen to flash and I lose all prior text.

Is there a good method of keeping only X lines in a RichTextBox?

Logs could be coming in quickly ... so are there any high performance
methods of doing this?
One more thing, if you use a listview you can always ensure that the last
item added is visible by just setting the ensurevisible property when you
create the listviewitem

Lloyd Sheen

Jun 7 '07 #3
On Jun 7, 2:44 pm, Spam Catcher <spamhoney...@rogers.comwrote:
Hi all,

Is it possible to do a console like scrolling window in a Windows Form app?

The closest I've gotten is to use a RichTextBox and append text to it.

However, after a while, there is too much text, I need to clear the textbox
- this causes the screen to flash and I lose all prior text.

Is there a good method of keeping only X lines in a RichTextBox?

Logs could be coming in quickly ... so are there any high performance
methods of doing this?
I was just playing around with this and it seems to not do to bad
performance wise. Hopefully it will help you out:

Public Class FlashlessRTB ' Though it's not quite flashless :-)
Inherits RichTextBox

Public Sub New()
MyBase.New()
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
End Sub

Private _MaxLines As Integer = 10
Public Property MaxLines() As Integer
Get
Return _MaxLines
End Get
Set(ByVal value As Integer)
_MaxLines = value
End Set
End Property

Public Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal value As String)
MyBase.Text = value
TrimLines()
End Set
End Property

Public Sub TrimLines()
While Me.Lines.Length MaxLines
Try
preventPainting = True
Me.Text = Me.Text.Substring(Me.Lines(0).Length + 1,
Me.Text.Length - (Me.Lines(0).Length + 1))
Me.SelectionStart = Me.Text.Length
Finally
preventPainting = False
End Try
End While
End Sub

Private preventPainting As Boolean = False

Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
' Kill any WM_PAINT messages
If (Not preventPainting OrElse m.Msg <&HF) Then
MyBase.WndProc(m)
End If
End Sub

End Class

Let me know how it works out.

Thanks,

Seth Rowe

Jun 7 '07 #4
rowe_newsgroups <ro********@yahoo.comwrote in
news:11**********************@q66g2000hsg.googlegr oups.com:
Let me know how it works out.

Thanks,

Seth Rowe

Hi Seth,

Thanks for the code, I'll give it a go :-)

Jun 8 '07 #5
"Lloyd Sheen" <a@b.cwrote in
news:AB**********************************@microsof t.com:
This might be overkill but I have used a virtual list ListView control
to do somewhat the same.
I had thought about using a ListView too - but each row can only have 1 row
of text right? Unfortunately some of my log messages span multiple rows.
Also there's no copy/paste feature with a listview.

I use a listview for some of my logging in other apps too :-)
Jun 8 '07 #6

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

Similar topics

2
by: yootzee | last post by:
Greetings all, I'm having a problem with scrolling vertically in a newly created browser window. The vertical scrolling is to reach some anchor point within the new browser window. I'm...
1
by: Midas NDT Sales | last post by:
I have been looking at a simple example of a scrolling text box (the one in the SAM book) as below: <script language="JavaScript"> var pos=100; function Scroll() { if...
3
by: spencer | last post by:
Hello, I have an index page with an autoscroller writen with CSS. The problem is the scrolling content(text and inages)'s position is correct but will off position when the broswer(IE) window...
3
by: Vikram Bhatia | last post by:
1. Is there an event to capture scrolling using mouse wheel in Netscape 6.x? 2. When arrow keys are used to scroll a page in Netscape 6.x, the scrolling offsets obtained using...
2
by: James CC | last post by:
I have a strange bug in C# using windows forms. To make sure it's not some bug with my code, I've gone back to a simple test app, and still see the same behavior. I have created a simple C#...
5
by: Will Gillen | last post by:
I need to have a "scrolling" text label or textbox at the bottom of my window to show the URL of where a song is being played from. I want the text to scroll on a single line from left to right in...
2
by: P2P | last post by:
Hi I am wondering if someone know of a free cross-browsers vertical scrolling script that - is cross cross-browsers - will call the scrolling content from an external html page or from a...
4
by: Keith Bentrup | last post by:
Hi all, I wrote a simple search function to find text in a textarea where not all the text is visible (ie. the text box displays 10 lines but there may be more than 1000 lines to search). I can...
3
by: Chamnap | last post by:
Hello everybody, I have one problem. I want to do something after the user finished scrolling. The scroll event fires whenever the user is scrolling. I don't want this actually. Does anyone has...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.