Solved

Implement a sliding window textbox

Posted on 2008-11-02
4
520 Views
Last Modified: 2008-11-03
Hi,
I am looking for the most efficient way to create a textbox to monitor comms data.

I need to limit it's size to 100 lines so when a new line arrives, it is added to the bottom and if the no. lines in the textbox >100 the first one is removed.

The behaviour would be similar to that of the hyperterminal window (cant see all data just latest x lines).

I need to do this in a highly performant manner.
Please advise on the best way to go about it. ps. not wedded to a text box so use another control if it suits.

(using visual studio 2005)

thanks.
Shaun
0
Comment
Question by:sdom100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
alex_paven earned 450 total points
ID: 22863704
One way would be using a listbox, setting its datasource to a System.ComponentModel.BindingList<string> and working with the bindinglist; any changes you make in the list will be reflected in the control. If you need a textbox or similar control, you can inherit the bindinglist and provide a member that concatenates properly the list contents (100 is a relatively 'low' number for a stringbuilder, but calling it in a tight loop would indeed decrease performance). Other alternatives would include building a custom control that keeps track of changes in the list and paints the list as you see fit.
0
 
LVL 30

Assisted Solution

by:anarki_jimbel
anarki_jimbel earned 50 total points
ID: 22864247
My first thought was same as alex_paven's idea. I'd use a ListBox with the datasourse of the List<string> datatype. But I'd write my own class for this datasource List that would inherit from List<>. Basicly, I'd rewrite an Add() where I'd track number of lines and cleared items at the beginning of the list etc.
0
 

Author Comment

by:sdom100
ID: 22865261
My latest approach was to go with the listbox as suggested and simply use the add, check the items.count if >100 then use the RemoveAt function to take off the first line.
Which is most efficient ? (this way or using binding as per your suggestions) ?

Thanks,
Shaun
0
 
LVL 6

Expert Comment

by:alex_paven
ID: 22865270
Hard to say without testing, but I'd say the difference is minimal; the same mechanisms are used in both cases.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question