How add button programmatically in RadioButton?

I want create an horizontal menu bar, but it's no easy like the list box add an item, in this case item is a button.

In the previous article you saw how customize classic radio button to have a flat button with two state.

I want create an horizontal menu bar, but it’s no easy like the list box add an item, in this case item is a button. 

Now we want know how add a button programmatically.

Vi scripting help us to do this.

First step enable vi scripting.

With script code you can do this:

Move method, has a duplicate option that create a copy of the control.

This work only in edit mode, than it’s not usable to create my menu at runtime. It’s true that’s I need to know the item before to create action for each item. But figure out you want create dynamic menu, you can use this solution.

You can use it to create quickly other button in the radio with the same flat style of the last button you’re created.

Code to copy last button

Now if you using subpanel, the menu is in a separated Vi, then before you run this you can use the move method to configure you’re menu. A simple trick is to abort and after update the menu, run the Vi.

In the sample each times “Update Menu” is pushed a button is added .

Now creating an array of string that changes the boolean text you have something like the list box menu but button based and with horizontal or vertical arrangement autosizing.

However is not completely useful add a button at run time if you don’t have piece of code that do something for new button created. I use this to create a menu from template, and with some creativity you could use the caption string or boolean text to prepare the code need in case you create this buttons, in example.

About the Move Object Method that inspire me, see this Tutorial.

Scopri i nostri servizi e Prodotti, Contattaci ora!

Potrebbe interessarti anche

La taratura delle schede di acquisizione è un passaggio fondamentale per garantire la precisione e l’affidabilità delle macchine di collaudo in produzione. Tuttavia, il processo di taratura può essere lungo e costoso, soprattutto se si deve trasportare ogni volta le schede di acquisizione presso un laboratorio specializzato. Inoltre, il fermo macchina per l’attesa delle tarature o la necessità di pagare un servizio costoso può causare interruzioni alla produzione.
I sistemi di avvitamento di precisione, permettono serraggi esatti, dove coppia e posizionamento del serraggio garantiscono la Qualità e Affidabilità del prodotto.