By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,631 Members | 1,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,631 IT Pros & Developers. It's quick & easy.

FIFO Text Control

P: n/a
I have an application that recieves text data via external input (i.e.
serial) and displays it on the screen (we use carraige return as a
delimiter). At this point I use a regular old text box and when the
text size gets too big I truncate the string and re-set the
TextBox.Text property. This solution is very crappy as it creates a
flickering scroll bar when I re-set the text. Scrolling is also
difficult because the position in the text jumps to the end when I
append something new.

So, I have decided that I need to write a user control that will allow
me to do the following:

- Display text as it is received by the application
- Set the max number of characters (or lines) that can be displayed
- Create a FIFO style of adding text, so once the max number of
characters are reached, the display text is truncated from the
beginning and added at the end, without having the scroll bar jump
around
- Have a way of controlling the position displayed so I can scroll up
and view older text while new text is being added (i.e. you can hold
the scroll bar and the text stays put until you let go. I saw this in
Tera Term. Neat feature.)
- Nice to have: Select a truncate character (i.e. Carriage Return) so
that instead of loosing x number of characters, the text is truncated
by "line".

I'm totally stumped as I've never had to try this sort of thing before.
I'm considering a Panel of Labels that displays each "line" separately
and then adds/removes the controls to create the FIFO effect. I could
use a scroll bar to scroll up and down in the panel...maybe? The
problem is when I want to start re-sizing forms, the text won't really
format correctly unless I start doing some pretty wierd calculations
and grow the height of the label when the width shrinks.

So, any ideas where to start with this???

Cheers,
Russ

Jun 10 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
It sounds to me just few lines a code adding to a winform with textbox
control around. I don't think creating user control will make it work
better.

chanmm

"Dinsdale" <ru********@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
I have an application that recieves text data via external input (i.e.
serial) and displays it on the screen (we use carraige return as a
delimiter). At this point I use a regular old text box and when the
text size gets too big I truncate the string and re-set the
TextBox.Text property. This solution is very crappy as it creates a
flickering scroll bar when I re-set the text. Scrolling is also
difficult because the position in the text jumps to the end when I
append something new.

So, I have decided that I need to write a user control that will allow
me to do the following:

- Display text as it is received by the application
- Set the max number of characters (or lines) that can be displayed
- Create a FIFO style of adding text, so once the max number of
characters are reached, the display text is truncated from the
beginning and added at the end, without having the scroll bar jump
around
- Have a way of controlling the position displayed so I can scroll up
and view older text while new text is being added (i.e. you can hold
the scroll bar and the text stays put until you let go. I saw this in
Tera Term. Neat feature.)
- Nice to have: Select a truncate character (i.e. Carriage Return) so
that instead of loosing x number of characters, the text is truncated
by "line".

I'm totally stumped as I've never had to try this sort of thing before.
I'm considering a Panel of Labels that displays each "line" separately
and then adds/removes the controls to create the FIFO effect. I could
use a scroll bar to scroll up and down in the panel...maybe? The
problem is when I want to start re-sizing forms, the text won't really
format correctly unless I start doing some pretty wierd calculations
and grow the height of the label when the width shrinks.

So, any ideas where to start with this???

Cheers,
Russ

Jun 10 '06 #2

P: n/a
SP

"Dinsdale" <ru********@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
I have an application that recieves text data via external input (i.e.
serial) and displays it on the screen (we use carraige return as a
delimiter). At this point I use a regular old text box and when the
text size gets too big I truncate the string and re-set the
TextBox.Text property. This solution is very crappy as it creates a
flickering scroll bar when I re-set the text. Scrolling is also
difficult because the position in the text jumps to the end when I
append something new.

So, I have decided that I need to write a user control that will allow
me to do the following:

- Display text as it is received by the application
- Set the max number of characters (or lines) that can be displayed
- Create a FIFO style of adding text, so once the max number of
characters are reached, the display text is truncated from the
beginning and added at the end, without having the scroll bar jump
around
- Have a way of controlling the position displayed so I can scroll up
and view older text while new text is being added (i.e. you can hold
the scroll bar and the text stays put until you let go. I saw this in
Tera Term. Neat feature.)
- Nice to have: Select a truncate character (i.e. Carriage Return) so
that instead of loosing x number of characters, the text is truncated
by "line".

I'm totally stumped as I've never had to try this sort of thing before.
I'm considering a Panel of Labels that displays each "line" separately
and then adds/removes the controls to create the FIFO effect. I could
use a scroll bar to scroll up and down in the panel...maybe? The
problem is when I want to start re-sizing forms, the text won't really
format correctly unless I start doing some pretty wierd calculations
and grow the height of the label when the width shrinks.

So, any ideas where to start with this???


I would start with the Queue<T> object that will handle your FIFO
requirements. This has a ToArray method that will create a string array that
you can join using String.Join. You can then set the Text of a control like
TextBox. For the scrolling requirements I would use a flag to stop the
updating of the Text when the using is scrolling.

SP
Jun 10 '06 #3

P: n/a
The Queue idea is interesting (although I'm using 1.1).

Maybe it's just my implementation, but when I change the text of the
text box, the scroll bar and the text jumps around. That's why I
thought I might need to create a control.

//strMessage is the new data.

if (txtComms.Text.Length > MAX_MESSAGE_DISPLAY)
{
intLengthToRemove = strMessage.Length + (txtComms.Text.Length -
MAX_MESSAGE_DISPLAY);
txtComms.Text = txtComms.Text.Remove(0,intLengthToRemove + 1);
}
txtComms.AppendText(strMessage + "\r\n");

Any idea's how to prevent this jumping? The jumping is pretty annoying
when data is coming in quickly. I would like to avoid truncating large
sections of earlier data to lessen 'jumping' as it's furstrating when
you loose the line you needed when 10,000 characters get erased.

SP wrote:
"Dinsdale" <ru********@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
I have an application that recieves text data via external input (i.e.
serial) and displays it on the screen (we use carraige return as a
delimiter). At this point I use a regular old text box and when the
text size gets too big I truncate the string and re-set the
TextBox.Text property. This solution is very crappy as it creates a
flickering scroll bar when I re-set the text. Scrolling is also
difficult because the position in the text jumps to the end when I
append something new.

So, I have decided that I need to write a user control that will allow
me to do the following:

- Display text as it is received by the application
- Set the max number of characters (or lines) that can be displayed
- Create a FIFO style of adding text, so once the max number of
characters are reached, the display text is truncated from the
beginning and added at the end, without having the scroll bar jump
around
- Have a way of controlling the position displayed so I can scroll up
and view older text while new text is being added (i.e. you can hold
the scroll bar and the text stays put until you let go. I saw this in
Tera Term. Neat feature.)
- Nice to have: Select a truncate character (i.e. Carriage Return) so
that instead of loosing x number of characters, the text is truncated
by "line".

I'm totally stumped as I've never had to try this sort of thing before.
I'm considering a Panel of Labels that displays each "line" separately
and then adds/removes the controls to create the FIFO effect. I could
use a scroll bar to scroll up and down in the panel...maybe? The
problem is when I want to start re-sizing forms, the text won't really
format correctly unless I start doing some pretty wierd calculations
and grow the height of the label when the width shrinks.

So, any ideas where to start with this???


I would start with the Queue<T> object that will handle your FIFO
requirements. This has a ToArray method that will create a string array that
you can join using String.Join. You can then set the Text of a control like
TextBox. For the scrolling requirements I would use a flag to stop the
updating of the Text when the using is scrolling.

SP


Jun 11 '06 #4

P: n/a
SP

"Dinsdale" <ru********@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
The Queue idea is interesting (although I'm using 1.1).

Maybe it's just my implementation, but when I change the text of the
text box, the scroll bar and the text jumps around. That's why I
thought I might need to create a control.

//strMessage is the new data.

if (txtComms.Text.Length > MAX_MESSAGE_DISPLAY)
{
intLengthToRemove = strMessage.Length + (txtComms.Text.Length -
MAX_MESSAGE_DISPLAY);
txtComms.Text = txtComms.Text.Remove(0,intLengthToRemove + 1);
}
txtComms.AppendText(strMessage + "\r\n");

Any idea's how to prevent this jumping? The jumping is pretty annoying
when data is coming in quickly. I would like to avoid truncating large
sections of earlier data to lessen 'jumping' as it's furstrating when
you loose the line you needed when 10,000 characters get erased.
You can try using SuspendLayout and ResumeLayout. The problem is that the
scroll bar is adjusting it's size as the text changes although once it gets
to a certain number of lines the number of lines should then remain
constant.. I use a third party edit box control that seems to not be so
"jumpy" as the text is changed and it allows you to scroll back while text
is being added. As such I have never implemented the queue idea. Your
question made me think of a better implementation than what I am currently
doing which is similar to what you are currently doing. One idea is to turn
off the scroll bars in the text box and implement your own scroll bar
control.

SP


SP wrote:
"Dinsdale" <ru********@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
>I have an application that recieves text data via external input (i.e.
> serial) and displays it on the screen (we use carraige return as a
> delimiter). At this point I use a regular old text box and when the
> text size gets too big I truncate the string and re-set the
> TextBox.Text property. This solution is very crappy as it creates a
> flickering scroll bar when I re-set the text. Scrolling is also
> difficult because the position in the text jumps to the end when I
> append something new.
>
> So, I have decided that I need to write a user control that will allow
> me to do the following:
>
> - Display text as it is received by the application
> - Set the max number of characters (or lines) that can be displayed
> - Create a FIFO style of adding text, so once the max number of
> characters are reached, the display text is truncated from the
> beginning and added at the end, without having the scroll bar jump
> around
> - Have a way of controlling the position displayed so I can scroll up
> and view older text while new text is being added (i.e. you can hold
> the scroll bar and the text stays put until you let go. I saw this in
> Tera Term. Neat feature.)
> - Nice to have: Select a truncate character (i.e. Carriage Return) so
> that instead of loosing x number of characters, the text is truncated
> by "line".
>
> I'm totally stumped as I've never had to try this sort of thing before.
> I'm considering a Panel of Labels that displays each "line" separately
> and then adds/removes the controls to create the FIFO effect. I could
> use a scroll bar to scroll up and down in the panel...maybe? The
> problem is when I want to start re-sizing forms, the text won't really
> format correctly unless I start doing some pretty wierd calculations
> and grow the height of the label when the width shrinks.
>
> So, any ideas where to start with this???


I would start with the Queue<T> object that will handle your FIFO
requirements. This has a ToArray method that will create a string array
that
you can join using String.Join. You can then set the Text of a control
like
TextBox. For the scrolling requirements I would use a flag to stop the
updating of the Text when the using is scrolling.

SP

Jun 12 '06 #5

P: n/a
I'll keep you posted on my progress. This isn't a high priority item so
please be patient; I only have so much personal time to devote to my
geekiness.

:-)

Russ

SP wrote:
"Dinsdale" <ru********@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
The Queue idea is interesting (although I'm using 1.1).

Maybe it's just my implementation, but when I change the text of the
text box, the scroll bar and the text jumps around. That's why I
thought I might need to create a control.

//strMessage is the new data.

if (txtComms.Text.Length > MAX_MESSAGE_DISPLAY)
{
intLengthToRemove = strMessage.Length + (txtComms.Text.Length -
MAX_MESSAGE_DISPLAY);
txtComms.Text = txtComms.Text.Remove(0,intLengthToRemove + 1);
}
txtComms.AppendText(strMessage + "\r\n");

Any idea's how to prevent this jumping? The jumping is pretty annoying
when data is coming in quickly. I would like to avoid truncating large
sections of earlier data to lessen 'jumping' as it's furstrating when
you loose the line you needed when 10,000 characters get erased.


You can try using SuspendLayout and ResumeLayout. The problem is that the
scroll bar is adjusting it's size as the text changes although once it gets
to a certain number of lines the number of lines should then remain
constant.. I use a third party edit box control that seems to not be so
"jumpy" as the text is changed and it allows you to scroll back while text
is being added. As such I have never implemented the queue idea. Your
question made me think of a better implementation than what I am currently
doing which is similar to what you are currently doing. One idea is to turn
off the scroll bars in the text box and implement your own scroll bar
control.

SP


SP wrote:
"Dinsdale" <ru********@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
>I have an application that recieves text data via external input (i.e.
> serial) and displays it on the screen (we use carraige return as a
> delimiter). At this point I use a regular old text box and when the
> text size gets too big I truncate the string and re-set the
> TextBox.Text property. This solution is very crappy as it creates a
> flickering scroll bar when I re-set the text. Scrolling is also
> difficult because the position in the text jumps to the end when I
> append something new.
>
> So, I have decided that I need to write a user control that will allow
> me to do the following:
>
> - Display text as it is received by the application
> - Set the max number of characters (or lines) that can be displayed
> - Create a FIFO style of adding text, so once the max number of
> characters are reached, the display text is truncated from the
> beginning and added at the end, without having the scroll bar jump
> around
> - Have a way of controlling the position displayed so I can scroll up
> and view older text while new text is being added (i.e. you can hold
> the scroll bar and the text stays put until you let go. I saw this in
> Tera Term. Neat feature.)
> - Nice to have: Select a truncate character (i.e. Carriage Return) so
> that instead of loosing x number of characters, the text is truncated
> by "line".
>
> I'm totally stumped as I've never had to try this sort of thing before.
> I'm considering a Panel of Labels that displays each "line" separately
> and then adds/removes the controls to create the FIFO effect. I could
> use a scroll bar to scroll up and down in the panel...maybe? The
> problem is when I want to start re-sizing forms, the text won't really
> format correctly unless I start doing some pretty wierd calculations
> and grow the height of the label when the width shrinks.
>
> So, any ideas where to start with this???

I would start with the Queue<T> object that will handle your FIFO
requirements. This has a ToArray method that will create a string array
that
you can join using String.Join. You can then set the Text of a control
like
TextBox. For the scrolling requirements I would use a flag to stop the
updating of the Text when the using is scrolling.

SP


Jun 12 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.