Author Topic: How can I use Listbox?  (Read 3206 times)

LinesOfCodes

  • Newbie
  • *
  • Posts: 10
  • ?
    • S Universal Group - website
How can I use Listbox?
« on: September 26, 2020, 06:44:21 AM »
I want to use a Listbox but I don't know what command I have to type to use it the way I want.
I want to know:
  • How can I set heading text?
  • How can I Insert a value into the second column?
  • Can I run a command If the user double clicks on a row?
  • If HyperNext can't do the third one, then Can HyperNext script get the number of the row in the list that the user is selected?
  • How to add more columns

That's all I want to know.
I will ask the thing I doesn't know.

LinesOfCodes

  • Newbie
  • *
  • Posts: 10
  • ?
    • S Universal Group - website
Re: How can I use Listbox?
« Reply #1 on: September 27, 2020, 02:56:30 AM »
I try reading "Language Reference 401.pdf" on the download page.
Now I know how to add a value into the second column by using the "ListboxSetCellValue bid, row, col, val" command
  • bid: Field ID
  • row: What row you want to insert a value
  • col: What column you want to insert a value
  • val: Message you want to be insert

Set Heading text by using the "ListboxSetHeading bid, col, val"
  • bid: Field ID
  • col: Column you want to set the heading
  • val: Text you want to set

Get the currently selected row by using the "ListboxIndexFN(1)" command
usage: Put ListboxIndexFN(1) into num

That's all I know for Today.
I will ask the thing I doesn't know.

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 435
  • Here to help you
Re: How can I use Listbox?
« Reply #2 on: September 27, 2020, 09:54:39 AM »
I try reading "Language Reference 401.pdf" on the download page.
Now I know how to add a value into the second column by using the "ListboxSetCellValue bid, row, col, val" command
  • bid: Field ID
  • row: What row you want to insert a value
  • col: What column you want to insert a value
  • val: Message you want to be insert

Set Heading text by using the "ListboxSetHeading bid, col, val"
  • bid: Field ID
  • col: Column you want to set the heading
  • val: Text you want to set

Get the currently selected row by using the "ListboxIndexFN(1)" command
usage: Put ListboxIndexFN(1) into num

That's all I know for Today.

Thank you for partially answering your own questions and so helping others :)

I'll add some example code in the post below.



I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 435
  • Here to help you
Re: How can I use Listbox?
« Reply #3 on: September 27, 2020, 10:55:24 AM »
In these examples the listbox has the ID 1, and has 3 columns and 10 rows.

Before starting with a listbox its usually best to reset it because HN can remember the final structure from when the project was previously run in Creator.

Code: [Select]
ListboxDeleteAll(1)

A listbox can also be set up in the card's opening event so making it appear instantly.
When editing a card's script or its controls:
   The opening event is the first item in the leftmost column of the listbox entitled "Card".
   Any items listed after the card's opening event are all for for controls such as buttons fields etc,

Set a listbox to have 3 columns:
Code: [Select]
ListboxSetColumns(1,3)

Alternatively you could build a 3 column listbox having 10 rows using the ListboxBuild command:
Code: [Select]
ListboxBuild(1,10,3)




  • How can I set heading text?

Code: [Select]
ListboxSetHeading(1,1,'Title 1')
ListboxSetHeading(1,2,'Title 2')
ListboxSetHeading(1,3,'Title 3')



  • How can I Insert a value into the second column?

So to set the listbox cell column 2 and row 9, to value 'hello' use:
Code: [Select]
ListboxSetCellValue(1,9,2,'hello')



  • Can I run a command If the user double clicks on a row?

Your script can check for various listbox events using the function ListboxEventFN(id):

For instance, this code checks if a cell was clicked. When a cell is clicked, it finds the cell coordinates and then calls a user-defined procedure to do something.
Code: [Select]
Local event,row,col

Put ListboxEventFN into event
If event=2 then
    Put ListboxRowClickedFN(1) into row
    Put ListboxColumnClickedFN(1) into col   
    Put ListboxCellValueFN(1,row,col) into txt
    Call DoSomething(row,col,txt)
endif

Note, a listbox's script is only called in response to an event such as when the user clicks a cell, drops a file on it, etc.

Here are the event numbers and descriptions:
         1 - Cell action either editable cell or checkbox clicked.
         2 - Cell clicked.
         3 - Drag reorded rows.
         4 - Drag row.
         5 - Drop drag.
         6 - Drop file.
         7 - Double click.
         8 - Header pressed
         9 - Cell key down.
         10 - Cell got focus.
         11 - Cell text change.
         12 - Cell lost focus.
         13 - Sort column.




  • How to add more columns

The ListboxSetColumns(id,ncols) changes the number of columns, for instance to 5, in this code:
Code: [Select]
ListboxSetColumns(1,5)

Note, if you want to add a row use the ListboxAddRow(id,value) command.
It adds value into the first cell of the new row.
Code: [Select]
ListboxAddRow(1,'cell value')
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

 

anything