09-24-2013 09:04 AM
Hello all
I have a VI which sends packets of data to a device and receives data. This is done using the serial port. I timestamp each packet and display it in a string control. I would like to be able to differentiate between sent and received packets by changing their colour / background / anything. I have investigated using a string control, a table, a list box and a richtextbox, but I am struggling to come up with a good solution. In the past in VB/C#.NET, I have created a log control using a richtextbox which can display formatted text, but I am keen to use a Labview control because I assume their is an overhead with the .NET richtextbox.
Any help or suggestions would be appreciated,
Thanks
Ray
09-24-2013 09:49 AM
The first control I tried to use, a Listbox, worked OK. I found the "trick" was to set the following properties together.
Active Row >> Active Row Number
Active Row >> Cell Font >> Color
09-25-2013 02:09 AM
Thanks Don, but I think I have not explained myself properly.
I would like the items to be added to the control in real time and to be colour coded in real time - I don't want to go back and apply the colours afterwards as there could be a few thousand packets of data. Here's a mock up:
I would add new packets to the top and everything moves down, retaining the colours.
I have had a go with the listbox as you suggest and can't get this functionality - although this may just be my limited knowledge of listboxes...
Thanks,
Ray
09-25-2013 02:43 AM
Here's a bit more information.. My current string control looks like this:
and it would be much more intuitive if it looked like this (without the "SENT:" prefix):
09-25-2013 06:48 AM
Something like this?
I used a listbox with selection mode 0 (0 or 1 items selected) and Disabled, so that the user cannot click and highlight on any item.
The string to be displayed is to be given to ItemNames property. The cell background can be set as per your need. I have just set alternate cells to different colours.
09-25-2013 06:59 AM
Hi btanmay
Thanks for the reply and the demo VI. I can apply the colour coding to a completed string, but I would like to do it as the messages arrive. So my string / display control retains the colour coding information and I just add another entry with the correct colouring which is then retained. I would like the control to be able to hold a few thousand lines and I don't want to parse the control and re-apply the colour code every time I add a new entry.
09-25-2013 08:06 AM - edited 09-25-2013 08:08 AM
@Tarsel wrote:
I would like the control to be able to hold a few thousand lines and I don't want to parse the control and re-apply the colour code every time I add a new entry.
The messages themselves could be stored in a shift register array and wired to the Item Names property so updating the entire list shouldn't be problematic. You could even have the array backwards (so new messages are added to the end) and then reverse the array just prior to wiring to the control. This reduces memory usage for updating the array compared to inserting at the start of an array.
Unfortunately, the color settings are for an individual cell/row of a listbox can not be simply updated with an array of color values. These would have to be updated for each individual row (since you plan to add new messages to the front, all cell colors are subject to change at each update).
09-25-2013 09:01 AM
Hi pjr1121
Your last sentence is the issue I have found with a listbox - I would need to keep an array of colour information alongside my listbox!
As I mentioned, I have succeeded with the coloured log list previously in .NET using a richtextbox, but I have struggled with the control in Labview.
09-25-2013 12:05 PM
That is correct.
You will have to build a cluster with {TheString,TheColor} store this in an extra array that gets updated. You delete old, add new and so on.
When ever needed you rewrite the array to the list.
Be sure to use "defer panel updates" while you are writing.
Gabi
09-25-2013 12:24 PM
Attach your VI, I bet it won't be all that hard to color code the way you want, but I'd like to see just what you have to work with.
Cameron