Re: Win32Lib; Control; Dropdown; Index and data?

new topic     » goto parent     » topic index » view thread      » older message » newer message

ZNorQ wrote:
> 
> I've got database table content that I want to be presented in a dropdown
> control. I'm not gonna put inn all the field values in the control, but I
> need the unique index and the readable information.

Does this sort of thing help?

---------
include win32lib.ew
without warning
integer vWin
integer vList
sequence theDataBase
theDataBase =
{
 { 17, "Olsen",  "Elvis"},
 {201, "Jensen", "Thor"},
 { 39, "Jordan", "Jens"},
 {411, "Jordan", "Jens"} -- Duplicate name test
}
procedure AddKey(integer id, object item)
    sequence lKeys

    lKeys = getUserProperty(id, "Key")
    if length(lKeys) != 0 then
        lKeys = lKeys[1]
    end if

    lKeys &= item

    setUserProperty(id, "Key", lKeys)
end procedure

procedure Change_List(integer self, integer event, sequence parms)
    sequence lKeys

    lKeys = getUserProperty(self, "Key")
    if length(lKeys) = 0 then
        return -- No keys defined.
    end if

    setText(vWin, sprintf("Key is %d", lKeys[1][parms[2]]))
end procedure

procedure load_database()
    for i = 1 to length(theDataBase) do
        addItem(vList, sprintf("%s, %s",
                    { theDataBase[i][2], theDataBase[i][3]}
                    )
                )
        AddKey(vList, theDataBase[i][1])
    end for
end procedure

procedure main()
    vWin = create(Window, "Drop Down Indexing", 0, 0, 0, 400, 400, 0)
    vList = create(DropDownList, "", vWin, 10, 10, 300, 300, 0)
    load_database()
    setHandler(vList, w32HChange, routine_id("Change_List"))
    WinMain(vWin, Normal)
end procedure
main()


-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu