LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change color in string boxes

Solved!
Go to solution

Hello again,

 

Please could you help me with a problem that I have not been able to solve. It happens that I have 3 text files with items NUM1, NUM2, NUM3 ... NUM10. and those items are displayed in a combobox. In addition to this I have 6 string cells where the same items appear (NUM1, NUM2, ... NUM10) but at random order. The user can modify these cells with random or consecutive values ​​of the NUM. My intention is to color the text depending on the user's selection. For example, if I select NUM 3 (left box) manually and select green option on combobox, I want that NUM 5 to turn green.

Mocte117_2-1730326903408.png

 

I think one way is to use the combobox where all the options are and select the option I require, the color and the apply button. Or manually select the letters I want to color, select the color and click apply.

 

What would you do?

 

 

 

0 Kudos
Message 1 of 14
(370 Views)

I would use lisboxes.

0 Kudos
Message 2 of 14
(358 Views)

I don't think you can change the color of different string lines, since they are on the same String indicator/control. 

One way to accomplish what you want is to replace the string boxes with a cluster with strings , in this case each string indicator will be independent and you can change the color independently with property nodes.

The cluster property node will give you an array of references for each string control/indicator, using a FOr loop you can setup the color of each individual. 

 

LVNinja_1-1730381358620.png

LVNinja_2-1730381377249.png

 

 

 

0 Kudos
Message 3 of 14
(312 Views)

@LVNinja wrote:

I don't think you can change the color of different string lines, since they are on the same String indicator/control. 

One way to accomplish what you want is to replace the string boxes with a cluster with strings , in this case each string indicator will be independent and you can change the color independently with property nodes.

The cluster property node will give you an array of references for each string control/indicator, using a FOr loop you can setup the color of each individual. 

 

LVNinja_1-1730381358620.png

LVNinja_2-1730381377249.png

 

 

 


You should be able to use the text selection property along with text.text color (foreground and background) to get the desired results.   It will get ugly with the string match indices (there may be an unusual off-by-one to account for the index after matches.)  

 

By ugly, I mean even CA won't get that to fit on a postage stamp!  But highly doable. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 14
(305 Views)

As I said, use listboxes and rings.

Can you explain how the saved files should look like? For example do you only want to save the colored items? (A plain text file will not retain color information).

 

You still have some glaring issues in general:

 

  • There is no event for the [apply] button
  • Your VI cannot be stopped. You need a stop button and an event for it.
  • All latch action booleans should be inside their event case so they reset when the event is handled.
  •  Are you expecting the List*.txt files to constantly change by external causes? If not it would be sufficient to read the once and not with every iteration of the loop.
  • concatenating a single string returns the input unchanged. Delete these functions!
  • You don't need to wire the indices for index array if you want the elements in order (see picture)
  • Wouldn't it be more useful to have the "array" terminal on the loop diagram instead of inside the save event so we can see what will be saved before the same button is pressed?
  • Is the user allowed to randomly change the various strings and what should happen if he does?
  • ... etc etc.

 

 

altenbach_0-1730386263433.png

 

Message 5 of 14
(297 Views)
Solution
Accepted by topic author Mocte117

See if this quick draft can give you some ideas.

 

I still have absolutely no idea what you are trying to save, so I left that out.

You also should format your "masterlist.txt a little better. Having long sequences of spaces is not a good delimiter!

 

 

altenbach_0-1730390075031.png

 

Message 6 of 14
(285 Views)

Hi Knight Of NI, sorry to bother you again, I have a question, in case I want an item that opens in the MasterList.txt list to start with a default color, how should I do it? As I see, the LstBox (strict) sends all the items to the different listbox with the same color. I don't know if adding a case inside the loop would work.

 

The code for this area:

 

Mocte117_0-1731018371138.png

 

0 Kudos
Message 7 of 14
(114 Views)

solved 🙂

Mocte117_1-1731077696957.png

 

0 Kudos
Message 8 of 14
(95 Views)

You can wire the string directly to the Case and have ITEM as case selector instead. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 14
(92 Views)

I tried it but it doesn't work properly. Do you know what could be causing this problem? The solution I put previously also stopped working.

 

When I run the VI only some items are displayed in color, even those that do not belong to the specified condition

 

Mocte117_0-1731081473215.png

Mocte117_1-1731081544716.png

 

 

0 Kudos
Message 10 of 14
(76 Views)