Submitted by JXB on Fri, 03/06/2015 - 11:20
Forums:
To all,
A stupid question (I partially know the answer but just in case!).
What is the best/quickest/simplest way of creating a list box to present a list of NX AFU record name to a user and allow them to select one or more.
Thanks
Regards
JXB
re: listbox
Do you have access to the NX blockstyler? or do you want to create your own windows form?
re: listbox
Went for the NX blockstyler option. As I got some help for a very kind soul over the week end
Wrestling with the user selection from a list box at the moment. I am getting the index of the selection but I am looking for the keyword to get the "text of the selection as I'd like to pass an array (of string) containing all the user selections (from the list box) to another function
Thanks
Regards
re: listbox
Unfortunately, I won't be much help here as I do not currently have a license for the NX blockstyler.
re: listbox
That's OK. The following seems to work
Dim theListboxselection() As String
theListboxselection= list_box0.GetSelectedItemStrings
If Ubound(theListboxselection) > 0 Then
For i = Lbound(theListboxselection) to Ubound(theListboxselection)
TheLW.WriteLine("---selection is :" &theListboxselection(i) )
Next
GetonItwithIt(theListboxselection)
Thanks
Regards
List box
The simplest is Snap.UI.Input.GetChoices:
Option Infer On
Imports Snap, Snap.Create, Snap.UI.Input
Public Class MyProgram
Public Shared Sub Main()
Dim cue As String = "Please choose your favorite Beatles"
Dim title As String = "Beatle Chooser"
Dim label As String = "Choose at least two"
Dim beatles As String() = {"John", "Paul", "George", "Ringo" }
Dim choices = GetChoices(beatles, cue, title, label)
For Each index in choices
InfoWindow.WriteLine(beatles(index))
Next
End Sub
End Class
RE: List box
Thanks for the suggestion ciao. I haven't used Snap in anger but the UI builder seem to do the job very nicely.
I haven't figures out which function is executed when the user presses the "Cancel" button as I'd like the theLW to be closed when the GUI is closed! I have tried theLW.Close() in Public Sub Dispose() but nothing. Must be somewhere! There is no function called 'cancel_cb' !!
Regards
JXB
Thanks
Regards
Re: Closing a listing window
You need to use
theLW.CloseWindow()
.The
.Close()
method only closes the text stream, not the window itself.Can you recommend a place
Can you recommend a place where i can get more info about listbox?
RE: Can you recommend a place
igor
Start with the 'NX Programming tool' help page (NX help). There is a section on Block UI Styler
Regards
JXB
Thanks
Regards
ListBox or ListingWindow
The discussion above is pretty confusing. Some of it is about ListBox (i.e. NXOpen.BlockStyler.ListBox) and some of it is about the Listing Window (NXOpen.ListingWindow). Two completely different animals.