Page 1 of 1

Primary key while interpreting data in ListIconGadget

Posted: Sat Jan 24, 2015 11:25 pm
by bbanelli
Greetings to all,

I have noticed that there is no (easy, or perhaps at all while considering multiplatform approach) to hide column in ListIconGadget, while this is essential in dealing with databases where you have to remember primary key in order to process further queries. In Windows, partial workaround is to make column width '0', but that doesn't work on other OS'es.

For that purpose, I am using the following structure:

Code: Select all

Structure DatabaseRow
  ID.i
  Array Columns.s(1)
EndStructure
so when selecting rows from database, I remember them with something like this

Code: Select all

NewList ListView().DatabaseRow
;Our imaginary query with 11 columns, 1st column is primary key and other 10
;are displayed in ListViewGadget
;...
While NextDatabaseRow(0)
  AddElement (ListView())
  ListView()\ID = Val(GetDatabaseString(0, 0))
  ReDim ListView()\Columns(9)
  For i = 1 To 10
    ListView()\Columns(i - 1) = GetDatabaseString(0, i)
  Next
Wend
And when I access them from ListIconGadget I merely use

Code: Select all

SelectElement(ListView(), GetGadgetState(#ListViewGadget))
to access appropriate one in the list.

Is there any more elegant way for that?

Re: Primary key while interpreting data in ListIconGadget

Posted: Sat Jan 24, 2015 11:38 pm
by netmaestro
You might consider Set/GetGadgetItemData for this, it seems perfect.

Re: Primary key while interpreting data in ListIconGadget

Posted: Sun Jan 25, 2015 1:29 am
by bbanelli
netmaestro wrote:You might consider Set/GetGadgetItemData for this, it seems perfect.
Is cursing forbidden with forum rules?

This is exactly what I need, however, I have never realized that function exists! :(

netmaestro, thank you very much for giving me a little RTFM tour; PB team, sorry for doubting you. :)