Listbox double click event

Hi everyone.

I have a list box that is populated by a MySQL database table. When i double click one of the records, i want to be able to get ID field of that row, which in this case is employeeID.
Eventually, the double click event will open another window and display more information about the record that i have double clicked on.
This is the code that populates the listbox, it is from one of the xojo example projects.
Thanks in advance

[code] If Not IsConnected Then
MsgBox(“Connect to the database first.”)
End If

DataList.DeleteAllRows

Dim sql As String
sql = “SELECT * FROM tblEmployees”

Dim data As RecordSet
data = mDB.SQLSelect(sql)

If mDB.Error Then
MsgBox("DB Error: " + mDB.ErrorMessage)
Return
End If

If data <> Nil Then
While Not data.EOF
DataList.AddRow(data.IdxField(1).StringValue, data.IdxField(2).StringValue, _
data.IdxField(3).StringValue)

  data.MoveNext
Wend
data.Close

End If[/code]

Hi Alex

I do quite of lot of the same sort of thing you are after …(I think) The issue I have faced is the opening and closing of the database. In itself it is not an issue when the DB is relatively small but as the database gets large and a user is making numerous double clicks to extract data from it then the app (mine at least) slow down. What I have done is to extract all the information (including the employeeID in your case) from the database (as above) including other data you might not need immediately once - say on the open event. In my case I either put the information not immediately required into the listbox but hide the column or into another hidden listbox which can be referenced immediately from the double click - other recommend using an array which may be better.

In the double click event you can reference the row of data, from your listbox to “lookup” the relevant data of a hidden listbox or hidden columns. Actually I tend to just use a pushbutton which shows the info using the listbox.listindex property. It easy and it works. Your displayed info can be written to a new window or hidden (non visible/or non active) areas on the reference window.

An example - I have a database of customers which is holding around 40 different pieces of information including a contact name, tel number, notes, website etc…for an vast array of events. The notes section is a “Blob” field and it is revealed when the user highlights (selects) the customer name from a drop down or listbox and then clicks a pushbutton called “View Customer Profile” which is a series of textfields/areas/listboxes contained in a hidden groupbox which is toggled visible/on-off using the “profile” pushbutton. All the customer data is extracted once by this point to save open and closing the database (which is extremely large) every few seconds.

I am sure the xojo gurus would have better ways to do this though

Hope this makes sense

Nick

ListBox.RowTag and ListBox.CellTag are typically used to hold information that you need but do not want displayed to the user.

Sounds like what i want. Thanks for the help