LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create grid of buttons returning number when pressed

Solved!
Go to solution

Hello,

 

I would like to create a grid of buttons that return a value when pressed. The button should later represent a channel number so that the user can select channels via the grid.
I think creating 100 buttons, arranging them and processing the data via 100 events is not really a good way. Does anyone have any ideas on how to implement this? Unfortunately, this requirement is quite strictly demanded by the user. Iam using LV 2025....

 

 

Best regards 

 

Ole 

0 Kudos
Message 1 of 11
(298 Views)

I found a simple solution...

0 Kudos
Message 2 of 11
(265 Views)

here is the vi:

0 Kudos
Message 3 of 11
(261 Views)

It would help to do a "save for previous", (2020 0r below) before attaching. Most here (including me!) don't have LabVIEW 2025 installed.

 

What are the requirements?

 

  • Should each button have it's own name?
  • Can it be a 2D array of buttons?
  • What mechanical actions is required?
  • Can only be one or can multiple buttons be true at any given time?
  • Must at least one be true?
  • The most flexible would be a cluster of buttons, but that's a lot of menial work. I cannot tell what you tried.
  • Instead of "herding" 100 buttons. I might use a 2D picture where you parse the mouse down coordinates and update the picture accordingly.

 

0 Kudos
Message 4 of 11
(219 Views)

OK, I had a quick look at your VI and you only seem to allow one "kanal" to be active. (buttons are latch action)

 

Here's equivalent code:

 

altenbach_1-1747240208108.png

 

You don't need the timeout event, it does nothing useful.

 

 

 

 

0 Kudos
Message 5 of 11
(209 Views)

Use a radio button.  No coding needed.

You can copy / paste buttons within radio button.  So 2 buttons becomes 4, 4 becomes 8, ...

 

George Zou
0 Kudos
Message 6 of 11
(191 Views)

They already had the complete cluster.

 

I wish there was an easy way to directly convert a cluster of boolean controls to a radiobutton control...

0 Kudos
Message 7 of 11
(172 Views)

@altenbach wrote:

They already had the complete cluster.

But re-create a radio button from scratch isn't that hard.

 

I wish there was an easy way to directly convert a cluster of boolean controls to a radiobutton control...

Just copy all the buttons in the cluster and paste to a radio button.


 

George Zou
0 Kudos
Message 8 of 11
(163 Views)
Solution
Accepted by ole_mech

Creating a cluster control (or radio button control) with 100s of individually named and labeled buttons is just way too tedious and inflexible.

 

As mentioned earlier an image would be much more scalable. All we need is a reusable subVI to create the "image" of a button array and now we have full control over size, #of rows/Columns, button labels, button and text colors, button sizes, fonts, etc. etc.

 

altenbach_1-1747261183590.png

 

 

altenbach_0-1747261168064.png

 

If the first click should instantly exit the subVI with the selection, the code would be even simpler! (not shown)

 

For a more general case, it would be easy to recreate the image with each mouse interaction, e.g. to toggle the color of the clicked "button". The possibilities are endless.

Message 9 of 11
(147 Views)

Hey guys! Thanks for the help. This was my first topic in this forum. @altenbach next time will try to stick to your suggestions regarding problem description! I marked the ButtonArray.vi as solution 🙂  

0 Kudos
Message 10 of 11
(123 Views)