如图所示(为省略图,每一行有很多参数,现只展示前面的部分),我想要实现一种功能:我设定第一行的参数,然后选定1,选择开始,程序就按照第一行的参数运行,同样,选择其他行就会按照其他行的参数运行,本来想用Multicolumn Listbox来实现,可是因为我每一行的每一个参数都是有设定其范围的,而且彼此之间存在约束关系,而Multicolumn Listbox好像不能实现设定里面的值吧?而且我的参数都是number形式,它的值应该是string形式的,所以我不知道是不是就不能用了。如果不行,我实在是不想在前面板上列N个numeric control控件,有没有别的控件可以实现我说的功能呢?
简单点说:程序运行前,我在类似图中的列表中输入参数,这个参数是有限定其取值范围和彼此关系的(同列的取值范围一样),输入完毕后,选定某一行,再选定开始键,程序就会按照该行的参数运行。
请高手指点迷津!!!
已解决! 转到解答。
Yes, you may use Multicolumn Listbox (MCLB) to achieve that.
Although MCLB items are of 2D string array, you may convert each row's numerical values into string, construct them into 1D string array, and insert into the 2D string array for updating to the MCLB.
PS: Attached a very simple and basic code showing how numeric values is converted into string array, and updated to the MCLB.
There are many ways of achieving the same...
As of editing of a row's data, you may make use of the Double-Click method to obtain the double-clicked row, index that row's data for editing purpose before re-insert it back to the MCLB.
PS: attached is one of examples that obtains double-clicked row number.
是我没看懂吗?我的意思是在Multicolumn Listbox中输入number,该number要限定其取值,然后再将number输出到控制程序中,你能再帮我解释一下吗?我的理解是,Multicolumn Listbox里无论我输入number还是string,它都养成string格式来处理,而我要的是numeric格式的,输出也是numeric格式的,怎样转换这种格式呢?而且我还要定义listbox里的number的取值,这个又怎么实现?
MCLB is for "displaying" purpose.
For parameters input...
Inputs of numerical parameters could be from a sub-VI that pops up for entries. Each numerical control's range may be set through its property node.
Once all parameters are entered, simply convert them (using the conversion functions found under String functions palette) into string, followed by constructing into string array for updating to the MCLB.
For editing of parameters...
By double-clicking on the MCLB's row, you may obtain the double-clicked row through its property method. With the obtained row number, you may index the array row, convert the elements into respective format i.e. string to numeric, and display them in a pop-up sub-VI for editing purposes.
Once edited, exiting the pop-up sub-VI will convert those parameters back to string array and update the MCLB.
You need to understand how MCLB works, as well as how to use conversion functions and controls properties.
Just a quick one...
Assuming that above is the mclb that display two rows of parameters.
On double-clicks, below sub-VI is pop-up, showing the item name and the value for editing purpose...
You will notice that 4.498 Mhz (string) from the mclb is now converted to numerical value for editing needs. Once edited, when user clicks the UPDATE button, this value is converted back to string and updated to the mclb.
If, for example, you have 10 parameters in one row, you only need 10 numeric controls (place in the editor sub-VI). Regardless of which row of parameters you double-clicked, the same editor sub-VI will be used for editing purpose.
Hope above make sense to you 🙂