1. Win32Lib; Control; Dropdown; Index and data?

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.

Example; Databasetable "TBL_PERSON" content;
-------------------------------------------
KEY      SURNAME            FIRST NAME
-------------------------------------------
0001     Olsen              Elvis
0002     Jensen             Thor
0003     Jordan             Jens
-------------------------------------------

I want this data to be presented in a dropdown control, with the 
index hidden, and the full name shown with "SURENAME, FIRST NAME".
When the user makes a selection, it is the KEY that is returned, not
the name itself.

Is this possible? This principle was taken from the dropdown control in
MS Access, and I was kinda hoping it would have the same function in Win32Lib.

Regards
Kenneth / ZNorQ

new topic     » topic index » view message » categorize

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

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.
> 
> Example; Databasetable "TBL_PERSON" content;
> -------------------------------------------
> KEY      SURNAME            FIRST NAME
> -------------------------------------------
> 0001     Olsen              Elvis
> 0002     Jensen             Thor
> 0003     Jordan             Jens
> -------------------------------------------
> 
> I want this data to be presented in a dropdown control, with the 
> index hidden, and the full name shown with "SURENAME, FIRST NAME".
> When the user makes a selection, it is the KEY that is returned, not
> the name itself.
> 
> Is this possible? This principle was taken from the dropdown control in
> MS Access, and I was kinda hoping it would have the same function in Win32Lib.
> 
> Regards
> Kenneth / ZNorQ

Hello ZNorQ,

If you mean a menu drop down that should be pretty simple.

Untested.
constant Menu_Item_0001=createEx(MenuItem,"0001   Olson
Elvis",Menu_Main,0,0,0,0,0)

function doIt(integer s,intrgedr e,sequence p) return "0001" end function SetHandler(Menu_Item_0001,routine_id("doIt")

Don Cole }}}

new topic     » goto parent     » topic index » view message » categorize

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

don cole wrote:
> 
> 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.
> > 
> > Example; Databasetable "TBL_PERSON" content;
> > -------------------------------------------
> > KEY      SURNAME            FIRST NAME
> > -------------------------------------------
> > 0001     Olsen              Elvis
> > 0002     Jensen             Thor
> > 0003     Jordan             Jens
> > -------------------------------------------
> > 
> > I want this data to be presented in a dropdown control, with the 
> > index hidden, and the full name shown with "SURENAME, FIRST NAME".
> > When the user makes a selection, it is the KEY that is returned, not
> > the name itself.
> > 
> > Is this possible? This principle was taken from the dropdown control in
> > MS Access, and I was kinda hoping it would have the same function in
> > Win32Lib.
> > 
> > Regards
> > Kenneth / ZNorQ
> 
> Hello ZNorQ,
> 
> If you mean a menu drop down that should be pretty simple.
> 
> Untested.
> }}}
<eucode>
> constant Menu_Item_0001=createEx(MenuItem,"0001   Olson 
> Elvis",Menu_Main,0,0,0,0,0)
> 
> function doIt(integer s,intrgedr e,sequence p)
>    return "0001"
> end function
> SetHandler(Menu_Item_0001,routine_id("doIt")
> 
> Don Cole

Hey Don,

Hehe, no not exactly. I was thinking of a combo drop-down.

The point is that when someone selects a name in the combo, the key index is
returned,
and not the name itself. While the index (key) is unique, the name can be
ambigious
which would cause a problem when I want to make a look-up in the database table
based
on the selected value in the combo.

The index doesn't tell the user much, so I need the readable information (ie.
the name)
to be visible, and the index to be invisible. When a user selects "Jensen, Thor"
- the
index 0002 will be returned, and the code can look up every record that have the
key
index = "0002" (which should in this case be just one).

Kenneth / ZNorQ

new topic     » goto parent     » topic index » view message » categorize

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

ZNorQ wrote:
> 
> don cole wrote:
> > 
> > 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.
> > > 
> > > Example; Databasetable "TBL_PERSON" content;
> > > -------------------------------------------
> > > KEY      SURNAME            FIRST NAME
> > > -------------------------------------------
> > > 0001     Olsen              Elvis
> > > 0002     Jensen             Thor
> > > 0003     Jordan             Jens
> > > -------------------------------------------
> > > 
> > > I want this data to be presented in a dropdown control, with the 
> > > index hidden, and the full name shown with "SURENAME, FIRST NAME".
> > > When the user makes a selection, it is the KEY that is returned, not
> > > the name itself.
> > > 
> > > Is this possible? This principle was taken from the dropdown control in
> > > MS Access, and I was kinda hoping it would have the same function in
> > > Win32Lib.
> > > 
> > > Regards
> > > Kenneth / ZNorQ
> > 
> > Hello ZNorQ,
> > 
> > If you mean a menu drop down that should be pretty simple.
> > 
> > Untested.
> > }}}
<eucode>
> > constant Menu_Item_0001=createEx(MenuItem,"0001   Olson 
> > Elvis",Menu_Main,0,0,0,0,0)
> > 
> > function doIt(integer s,intrgedr e,sequence p)
> >    return "0001"
> > end function
> > SetHandler(Menu_Item_0001,routine_id("doIt")
> > 
> > Don Cole
> 
> Hey Don,
> 
> Hehe, no not exactly. I was thinking of a combo drop-down.
> 
> The point is that when someone selects a name in the combo, the key index is
> returned,
> and not the name itself. While the index (key) is unique, the name can be
> ambigious
> which would cause a problem when I want to make a look-up in the database
> table
> based
> on the selected value in the combo.
> 
> The index doesn't tell the user much, so I need the readable information (ie.
> the name)
> to be visible, and the index to be invisible. When a user selects "Jensen,
> Thor"
> - the
> index 0002 will be returned, and the code can look up every record that have
> the key 
> index = "0002" (which should in this case be just one).
> 
> Kenneth / ZNorQ

I've done a similar thing with a listView.

  setHandler(ListView3,w32HChange,routine_id("select1"))

You could put the listView in a child window that drops down.


Don Cole

new topic     » goto parent     » topic index » view message » categorize

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

Sorry ZNorQ I forgot something.

global function select11()
    sequence this,text
    this=getLVSelected(ListView3)
          if length(this)>0 then
                text=getLVItemText(ListView3,this[1],1)
                --setText(SB,getLVItemText(ListView3,this[1],1))
            return getLVItemText(ListView3,this[1],1)
          else 
            return "  "
          end if
 end function

setHandler(ListView3,w32HChange,routine_id("select1"))

Don Cole }}}

new topic     » goto parent     » topic index » view message » categorize

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

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 message » categorize

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

Derek Parnell wrote:
> 
> 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?
> 
> }}}
<eucode>
> --------- 
> 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()
> </eucode>
{{{

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

Hello Derek,

Well to tell the truth I didn't even know that there was a control named
    DropDownList. It just goes to show you that there is something to be learned
    everyday reading this list.

    You must admit though that 
setHandler(vList, w32HChange, routine_id("Change_List"))

is very similar to
setHandler(ListView3,w32HChange,routine_id("select1"))

Don Cole }}}

new topic     » goto parent     » topic index » view message » categorize

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

don cole wrote:
> 
> Derek Parnell wrote:
> > 
> > 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?
> > 
> > }}}
<eucode>
> > --------- 
> > 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()
> > </eucode>
{{{

> > 
> > -- 
> > Derek Parnell
> > Melbourne, Australia
> > Skype name: derek.j.parnell
> 
> Hello Derek,
> 
>     Well to tell the truth I didn't even know that there was a control named
> DropDownList. It just goes to show you that there is something to be learned
> everyday reading this list.
> 
>     You must admit though that 
> }}}
<eucode>
>    setHandler(vList, w32HChange, routine_id("Change_List"))
> </eucode>
{{{

> is very similar to
> }}}
<eucode>
>   setHandler(ListView3,w32HChange,routine_id("select1"))
> 
> Don Cole

Hey Don & Derek,

I've been, and still are quite busy, but I test the code as soon as 
possible. I must say I'm impressed by the length you both are willing
to go to help out a poor sap like me. How the hell do you find the time??

Anyway, I really appreciate it.

I'll get back to you with some results as soon as I can.

Again, thanks guys.

Kenneth / ZNorQ

PS, Derek, I was sure you where gonna leave the Eu community, but
I must say it's cool that you're still replying to win32lib issues
that appears on the forum..

new topic     » goto parent     » topic index » view message » categorize

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

ZNorQ wrote:
> 
> don cole wrote:
> > 
> > Derek Parnell wrote:
> > > 
> > > 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?
> > > 
> > > }}}
<eucode>
> > > --------- 
> > > 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()
> > > </eucode>
{{{

> > > 
> > > -- 
> > > Derek Parnell
> > > Melbourne, Australia
> > > Skype name: derek.j.parnell
> > 
> > Hello Derek,
> > 
> >     Well to tell the truth I didn't even know that there was a control named
> > DropDownList. It just goes to show you that there is something to be learned
> > everyday reading this list.
> > 
> >     You must admit though that 
> > }}}
<eucode>
> >    setHandler(vList, w32HChange, routine_id("Change_List"))
> > </eucode>
{{{

> > is very similar to
> > }}}
<eucode>
> >   setHandler(ListView3,w32HChange,routine_id("select1"))
> > 
> > Don Cole
> 
> Hey Don & Derek,
> 
> I've been, and still are quite busy, but I test the code as soon as 
> possible. I must say I'm impressed by the length you both are willing
> to go to help out a poor sap like me. How the hell do you find the time??
> 
> Anyway, I really appreciate it.
> 
> I'll get back to you with some results as soon as I can.
> 
> Again, thanks guys.
> 
> Kenneth / ZNorQ
> 
> PS, Derek, I was sure you where gonna leave the Eu community, but
> I must say it's cool that you're still replying to win32lib issues
> that appears on the forum..

Hey Derek,

(Sorry Don, seems I'm going for Derek's code, no hard feelings? :P)

I've had a look at your code, Derek, and this is EXACTLY what I'm looking
for. I guess the power lies in the xxxUserProperty syntax.

Can I use the UserProperty code for ListView too, meaning for each
individual field in a list of items in a ListView?

Regards,
Kenneth / ZNorQ

new topic     » goto parent     » topic index » view message » categorize

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

ZNorQ wrote:

> Can I use the UserProperty code for ListView too, meaning for each
> individual field in a list of items in a ListView?

I'm not sure if I understand the question.

A User Property is associated with a control's ID. You can define any number of
properties for any of the controls.

So if you have a ListView called 'LV', for example, you can define a property
for each column (field?) like this ...

  defineUserProperty(LV, "Column 1", 0)
  defineUserProperty(LV, "Column 2", 0)
  defineUserProperty(LV, "Column 3", 0)
  . . .
  defineUserProperty(LV, "Column N", 0)

But I'm not sure why you would need to do that. What did you have in mind?

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

new topic     » goto parent     » topic index » view message » categorize

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

Derek Parnell wrote:
> 
> ZNorQ wrote:
> 
> > Can I use the UserProperty code for ListView too, meaning for each
> > individual field in a list of items in a ListView?
> 
> I'm not sure if I understand the question.
> 
> A User Property is associated with a control's ID. You can define any number
> of properties for any of the controls. 
> 
> So if you have a ListView called 'LV', for example, you can define a property
> for each column (field?) like this ...
> 
>   defineUserProperty(LV, "Column 1", 0)
>   defineUserProperty(LV, "Column 2", 0)
>   defineUserProperty(LV, "Column 3", 0)
>   . . .
>   defineUserProperty(LV, "Column N", 0)
> 
> But I'm not sure why you would need to do that. What did you have in mind?
> 
> -- 
> Derek Parnell
> Melbourne, Australia
> Skype name: derek.j.parnell

Hei Derek,

Just for get about it. After a re-cap, I don't see a specific need for this
at this time. I was thinking of editing items directly in a ListView, but
as far as I know this isn't possible anyway.

As for the userproperties on a combo, that has become quite helpful.

Thanks for the help.

Regards
Kenneth / ZNorQ.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu