04-17-2009 04:56 AM
I have an appln in which i need to create a certain number of string indicator(s)/control(s) based on a particular numeric selection made by the user. One thing that I can do is that create the max number of controls & use the Visible Property Node to show only the selected no. of controls. But by doing this my appln would become very complex. So if anyone could suggest me how it can be at run-time as this will save memory also.
Thanx in advance
Solved! Go to Solution.
04-17-2009 04:58 AM
Controls cannot be created at run-time. You've already identified the only method that will work for you - to create all your controls in advance and make them visible/invisible as required.
If you handle all these control references in an array, then your code shouldn't get unnecessarily complicated.
04-17-2009 06:07 AM
Jalpa wrote:I have an appln in which i need to create a certain number of string indicator(s)/control(s) based on a particular numeric selection made by the user. One thing that I can do is that create the max number of controls & use the Visible Property Node to show only the selected no. of controls. But by doing this my appln would become very complex. So if anyone could suggest me how it can be at run-time as this will save memory also.
Thanx in advance
Custom GUI graphic question are besy handled if you post a mock image illustrating your desired results.
Lacking images of what you want...
Thoric's reply re your approach is valid.
"Creating controls on the fly" is possible but it is not trivial (been ther done that).
Ben
04-17-2009 07:11 AM
Agree with Ben and Thoric, you can't create controls at Run-Time easily.
How to handle your situation - it depends from your final goals - you can create enough strings, then turn on/off with visible property, or may be reorganize your application - use tables/multicolumn list boxes instead of strings, use arrays of strings, etc.
Anyway, one possible way for creating controls in runtime in attachment. Here XControl with linked list used and with this VI you can "create" boolean buttons dynamically. This idea useful when you don't know initially - how many buttons you needed in your application (I started with this for dynamic creation of the ToolBar). You can replace Button with String in this example. May be this will be helpful for you.
Andrey.
04-17-2009 07:38 AM
Andrey - I'm having trouble getting your attached example to work. It loads fine, with no broken run arrow, but achieves nothing when the front panel buttons are selected. I'm no expert in XControls, so is it possible I need to turn on an option somewhere before the XControl will work?
(LV 8.6, WinXP SP3)
04-17-2009 07:45 AM
Close all other your projects. Open only attached example. Then it should work.
(FYI: problem located in Root_XControl.xctl:Create_New_Button.vi)
Andrey.
04-17-2009 07:55 AM - edited 04-17-2009 07:56 AM
04-17-2009 08:03 AM
Thanks. This code not completely my code. Thanks for one of NI Engineers (don't remember who is author exactly)
http://decibel.ni.com/content/docs/DOC-1209
Andrey.
05-02-2009 01:58 AM
Thanx Andrey
This is exactly what I was looking for "creating controls/indicators at run-time. I'l go through the links which demonstrate how XControls can be created coz finally I want to create a customized control at run-time, so will try to export the customized control to XControl.
09-26-2009 01:19 PM
You need to change your accepted solution. Now you can really create control/indicators at run time See this
http://forums.ni.com/ni/board/message?board.id=170&thread.id=443761
Tushar Jambhekar
tushar@jambhekar.com
Jambhekar Automation Solutions
LabVIEW Consultancy, LabVIEW Training
Rent a LabVIEW Developer, My Blog