simonongsk

NA HMI Listbox

10 posts in this topic

I read  http://forums.mrplc.com/index.php?/topic/33282-read-an-array-of-strings-from-nj-to-na/.  What I looking at is how to add items to Listbox with array from NX cpu.

 

There is no "Items.Add" member for the listbox. I hope the listbox for NA behave the same way like the NS or Proface.

as below code from the link above sure will not work

 

Sub ListBox_Update
    Dim List_obj As Object 
    Dim array(100) As String
    Dim x As Integer
    For x = 0 To 99
        array(x) = ListItems(x)
    Next x
    List_Obj = array
    listbox0.SetItems(List_Obj)
End Sub

Anyone  have try NA Listbox and please share your code

 

Thanks

 

 

 

 

Share this post


Link to post
Share on other sites

Used a listbox many times, but never tried loading the list anything other than manually.  My applications have not required me to get into the script code.

Share this post


Link to post
Share on other sites
1 hour ago, Crossbow said:

Used a listbox many times, but never tried loading the list anything other than manually.  My applications have not required me to get into the script code.

This part is easy. I thought since Omron advertised about VB.Net,  Then surely first thing come to my mind...listbox and Dropbox or even Textbox should behave as such in Visual Studio? if you read the link that I post, some one posted and said he/she had been able to load it from code. Or am i read wrongly?:-(

Share this post


Link to post
Share on other sites

I have used following code to update listbox contents:

Dim logs As System.Collections.Generic.List(Of Object) = Nothing

logs = New System.Collections.Generic.List(Of Object)
logs.Add("one")
logs.Add("two")
logs.Add("three")

lstLogViewer.SetItems(logs.ToArray())

But also your code should work if you modify it as following:

 Sub ListBox_Update    
    Dim array(100) As Object
    Dim x As Integer
    For x = 0 To 99
        array(x) = ListItems(x)
    Next x
    listbox0.SetItems(array)
End Sub 

NB! Your "ListItems" must be array of strings !
Basically: parameter passed to SetItems method must be array of objects, but those "objects" must be strings.

Edited by Fritz

Share this post


Link to post
Share on other sites
5 hours ago, simonongsk said:

...listbox and Dropbox or even Textbox should behave as such in Visual Studio?

No, actually not.

You can use VB.NET code in editor (Compact Framework 3.5) but visual components provided by Omron are not original .NET components. Those are Omron's own extremely limited versions. You can examine them with ILSpy from Omron libraries or use System.Reflection on runtime.

Edited by Fritz

Share this post


Link to post
Share on other sites

Fritz:

             There is a variable property for the Listbox, what do you specify? I think I compiled but with an error stated the setitems  is not an element  something.

I will give it a try ,.

Share this post


Link to post
Share on other sites
7 hours ago, Fritz said:

No, actually not.

You can use VB.NET code in editor (Compact Framework 3.5) but visual components provided by Omron are not original .NET components. Those are Omron's own extremely limited versions. You can examine them with ILSpy from Omron libraries or use System.Reflection on runtime.

Fritz:

             There is a variable property for the Listbox, what do you specify? I think I compiled but with an error stated the setitems  is not an element  something.

I will give it a try ,.

 

What is the listbox Memeber for selected item

 

ListBox0.SelectedItem.Value---> won't work

 

by the way VS2017 allow Campact FrameWork?

Share this post


Link to post
Share on other sites
On 4/23/2019 at 7:07 AM, simonongsk said:

             There is a variable property for the Listbox, what do you specify?

 

In properties page "variable" field can be left empty. It will show up as red box, but does not generate compile error. But basically this is your "selected index". Will work both ways.
If you leave "variable" field empty, then selected index can be read out and set also programmatically:
 

lstLogViewer.SelectedIndex = _selectedIndex

_selectedIndex = lstLogViewer.SelectedIndex

 

On 4/23/2019 at 7:07 AM, simonongsk said:

What is the listbox Memeber for selected item
ListBox0.SelectedItem.Value---> won't work

You can not read out selected item itself or it's value, only index.
To know the value, you need to keep track in you source array that was parameter in SetItems method.

As I said earlier - Omron's visual components are extremely limited.

Share this post


Link to post
Share on other sites

Thanks. As long as the Array stay the same with the index , value should be able to read but from the array instead of the Listbox0.

 

 

Share this post


Link to post
Share on other sites

Good afternoon.

 

Question on ListBox

 

The text of the program is to create a record in the ListBox is executed as intended.

 

 

  • Dim array(49) As Object

     

  • Dim x As Integer

     

  • For x = 0 To 49

     

  • array(x) = ListItems(x)

     

  • Next x

     

  • listbox0.SetItems(array)

     

 

 Also get the index of the selected row

  • Dim Num_row As Short
  • Num_row = listbox0.SelectedIndex.

 

Question - 

***** But I cannot understand how to manage the movement of the entire list up and down, without using the scroll bar.

 

I ask for help on the last question.

 

I tried to look for a solution in the component library - c:\Program Files (x86)\OMRON\SysmacStudio\Modules\DeviceHmi\V1.11\Runtime\Emulator\Omron.Hmi.Controls.dll with "ILspy".

 

But there at all not found elements - "listbox."

 

Edited by Yaros

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now