Badre Alam
13th September 2002, 14:29
D/Friends

Using BaaN 3GL I have developed a session in which Forms, ListBox, ComboBox is created dynamically and items/values added to the ListBox, even I trapped all the related events with the objects.

How to get the items from ListBox, what I want to know if any items is selected, in its click event or double click event I want to know the text of current selected item.

I tried all the way but could not do so.

Can any one help me out.......

Rgds

Alam Badre


Code that I have used for ListBox creation:

Function Create.ListBox(long hwnd)
{
listbox = Create.Object(DsClistBox, hwnd,
DsNallowMultiSelection, FALSE,
DsNbackground, motif.blue,
DsNforeground, RGB.WHITE,
DsNfocusColor, motif.blue,
DsNminWidth, 80,
DsNeventMask, EVTLISTBOXSELECTMASK,
DsNjustify, DSJUSTIFYLEFT,
DsNselectedId, 5,
DsNborderColor, RGB.WHITE,
DsNborderWidth, 2,
DsNmaxWindowSize, 200,
DsNspace, 0,
DsNx, xpos,
DsNy, 20)
Update.Object(listbox)


:)

mark_h
13th September 2002, 17:02
Have you seen this post. (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=1160&highlight=listbox). This might cover what you are looking for.

Mark

Badre Alam
18th September 2002, 06:23
Hi, Mark

I have gone thru all the replies on BaaNBoard related to ListBox but could not find any solution to my problem.

Really it is very difficult to writedown object /eventbased code in BaaN IV, trapping of events and all.

I am eager to find out how to get the value of items from ListBox.


Actual Code:

Function Create.ListBox(long hwnd)
{
listbox = Create.Object(DsClistBox, hwnd,
DsNallowMultiSelection, FALSE,
DsNbackground, motif.blue,
DsNforeground, RGB.WHITE,
DsNfocusColor, motif.blue,
DsNminWidth, 80,
DsNeventMask, EVTLISTBOXSELECTMASK,
DsNjustify, DSJUSTIFYLEFT,
DsNselectedId, 5,
DsNborderColor, RGB.WHITE,
DsNborderWidth, 2,
DsNmaxWindowSize, 200,
DsNspace, 0,
DsNx, xpos,
DsNy, 20)
Update.Object(listbox)
}


Function AddItem.To.ListBox(String users)
{
listboxitem =Create.Sub.Object(listbox, DsClistBoxItem, DsNstring, users, DsnItemcount)
}

Rgds

Alam Badre

RobertB
18th September 2002, 12:13
Hi Badre,

Mark actually pointed you in the right direction - if you follow the link he provided, and go to the bottom of the page, you will see a reference in the code there on how to access the properties of a listbox object.

Extract from example:

list.box = create.dropdown.listbox(some, arguments, here)
| Get the return index from the listbox...
if get.object(list.box, DsNselectedId, month.num) then

| Do something with the result...

endif
In the example, you receive the ID of the selected list-item in the third (reference) argument of the get.object() function (here called "month.num", since the example lists months of the year).

The get.object() function allows you to access many, if not all, of the properties of any Baan UI object from within a Baan script. Consult the Baan Tools help for more information on the UI objects.

HTH, RobertB