Labview : Changing color of boolean array, respectively - labview

I made this boolean array.
I want change the color of first boolean component as red, and second as blue.
This picture is what I want.
But when I change color property, three booleans change their color with together.
Is there any way to change color of boolean components, respectively?

Short answer: Just replace the boolean with a color box, as shown in the links in the other reply. It will simply be an array of color boxes instead of an array of booleans.
Long answer: An Array control contains an inner element control. The only property that can differ between elements of the array is the Value property. All other properties are rendered identically across elements of the array. If you need to differentiate the elements based on something other than the Value, you need to either use a different control that renders the graphical aspect that you want as its Value (i.e. replacing the Boolean with a Color Box) or you need to break out the N elements that you want to display as N separate independent controls and manage the updating of the display by yourself through code on the block diagram. This generally means creating your own scrollbar control or numeric control for controlling the index of the array.

You can always try to change your approach a little, try using clusters and if you need to use array, then create array of clusters. Here and here are similar subjects that should help you solving the problem with colors.

Related

How do you get an entire array from a structure?

I am making a board game and want to store information about each square of a 10x10 grid inside a structure, and I need to get the entire array rects from the record structure squares and use it in e.Graphics.FillRectangles(). Everything apart from the declarations are inside a paint event.
Public Structure squares
Dim rects As Rectangle
End Structure
Dim s(99) As squares
'assigning values to each instance of rects
e.Graphics.FillRectangles(b1, s.rects)
e.Graphics.DrawRectangles(p1, s.rects)
but this gives the error 'rects' is not a member of 'Form1.squares()'. s().rects does not work either. Note that I am not trying to get a specific index, as FillRectangles does not accept it as an argument.
I previously had rects on its own and that worked without any issues.
Dim rects(99) as Rectangle
'assigning values to each instance of rects
e.Graphics.FillRectangles(b1, rects)
e.Graphics.DrawRectangles(p1, rects)
I could use a loop that draws each rectangle individually, but I found that this method is much slower and not what i'm looking for.
Is there any way to make this work or should I have it as an array on its own and only store other information inside the structure? Should I even use a structure at all or would using parallel arrays be a better idea?
You cannot call s.rects. There is not an index to extract rects. That must be s(indexHere).rects.
However the code below return all rects from your array:
Dim s(99) As squares
'Do not forget to set rects before calling those two
e.Graphics.FillRectangles(Brushes.Red, s.Select(Function(x) x.rects).ToArray)
e.Graphics.DrawRectangles(Pens.Black, s.Select(Function(x) x.rects).ToArray)

Moving label to fit according to length vb.net

Hi I have a button which will add a string in to a label. (this can be done multiple times.) As the user can add multiple strings with each one been a different length, is there anyway I can get it to find the length of the label and those around it so that it spaces out correctly?
Thanks
Label.Width will return the current width of the label control, but it sounds like you already know this. Since the label can be narrower than the text it is trying to display, you would need to measure the full text using the graphics object. This method will return the width of the text in a label:
Private Function getFullTextWidth(lbl As Label)
Using g As Graphics = Label1.CreateGraphics()
Return g.MeasureText(Label1.Text, Label1.Font).Width
End Using
End Function
Alternatively, you could just set the label's AutoSize property to true, and then just check the label's Width property after you set the Text.

how to change the background color of an item in a listbox when its string value is equal to something?

i have a listbox that contains the words "week1", "week2", ..... all the way up to "week52" and when i select a week from the listbox it will retrieve a value from a mysql database that will represent a progress bar value. my progress bar has a range of 0-120 and i would like to have all the weeks that have values higher than 100 to be highlighted or marked somehow, in the listbox. so my question is, "is there a way to set the background color of certain weeks in the listbox to orange based on the value that they represent on the database?
for example for "week1", the value is 114, so when the listbox loads, i want the background color of the item "week1" in the list to be orange (indicating that it's current value is higher than 100)? i know that this requires me to implement a user defined drawing function for the listbox items but i dont know where i would even start. i would like this to be somewhat automatic so that it checks the values and changes the background colors of any value higher than 100, instead of me specifying a name of the item.
Thanks in advance!
I don't believe you can do this with a Listbox (at least not without creating your own implementation/subclassing/overriding/whatever of a Listbox).
Pretty sure you could do it with a ListView (in Detail mode), though, if that helps.

How would you make the text in a checkbox cell be able to be edited?

How would you make the text in a check box cell able to be edited like in a text cell instead of it just checking the Checkbox? The thing is that the Checkbox is Boolean in the Core Data Model and the Text is a String, so I don't know how I would make this work.
Have two columns: One with a checkbox cell and the other with a text cell, each bound to the appropriate property of your model objects.
Why use checkbox? The checkbox is designed to have two values only as you say. Therefore, you can try other controls, such as input area and so on. What I mean is that you can't make the rectangle to roll because it can't roll at all, right?

Pushing a list of colors into colordialog.customcolors

I have a list of colors i.e.: "1323523, 12342, 2354, 356234, 234234"
Each of these numbers stand for a color. I would like it so that when there is colordialog.showdialog, this list of colors shows up in the colordialog custom boxes.
this is how i am doing it currently, but for some reason the customcolors are not being added. i know for a fact that my array is good because i checked it.
Dim numberStrings = My.Settings.mytext1.Split(","c).Select(Function(x) x.Trim())
ColorDialog1.CustomColors = numberStrings.Select(Function(x) CInt(x)).ToArray()
Here is the documentation on the CustomColors property.
http://msdn.microsoft.com/en-us/library/system.windows.forms.colordialog.customcolors.aspx