ListBox RowTag

Using a ListBox. In VB I would assign a tag to a row for lookups.
So, I did this:
ListBox1.AddRow(data.IdxField(2).StringValue, data.IdxField(4).StringValue, data.IdxField(5).StringValue, data.IdxField(6).StringValue)
ListBox1.RowTag(Listbox1.LastIndex)=data.idxfield(1)

idxfield(1) = my SQL Row ID
When I do a MsgBox - It shows me the value.

Now, when I double click on a row, I need to get this RowTag value. It seems I might need to first get this into a public variable in ListBox.SelectionChanged. Then trigger the DoubleClick method.
Adding this code to SelectionChanged always results in an empty value.

Can anyone help?

put this is DOUBLECLICK event

  Dim row As Integer
  row=Me.RowFromXY(System.MouseX - Me.Left - Self.Left, System.MouseY - Me.Top - Self.Top)
  If row<0 Or row>Me.ListCount-1 Then Exit Sub
  Me.ListIndex=row
  msgbox me.rowtag(row)

You don’t need to manually change the listindex in the double click event since it will already be assigned before that fires. In the doubleClick event you can simply use:

if me.listindex<>-1 then theSelectedRowTag=me.rowtag(me.listindex) end if

Dave - your way told me things did not exist.
Tom - Your code gives me a “0” as well - which makes me think the tag is not getting applied.

ListBox1.RowTag(Listbox1.LastIndex)=data.idxfield(1)

It may be worth mentioning I am doing a Web Project.

be more specific and perhaps I can help… and maybe for a Web project they don’t… but this was not posted in the web section, so I assumed…

Tom… it didn’t used to work that way

This item does not exist:
row = Me.RowFromXY(System.MouseX (this part of the line is highlighted)

This item does not exist:
If row<0 row row>me.ListCount (this part of the line is highlighted)

It seems the web methods vs desktop methods do differ. i.e.: ListBox.SelectionType does not seem to exist in Web.

Re: My Post location: I could not find a section for web vs desktop - just a section for “Getting Started” - so I went for it. :frowning:

Back up a step. You’re saving IdxField(1), which is a DatabaseField that is embedded in a recordset. In other words, your saving a pointer to some object whose value may either get destroyed or modified by the time you retrieve it. Save the value instead.

ListBox1.RowTag(Listbox1.LastIndex)=data.idxfield(1).Value

It looks like you’re trying to assign the database field as the rowtag. You need to pick something that can properly be stored/called as a variant, such as the idxField.value to assign to the rowtag to properly call back from it later.

I should have picked up on that since we are using string value to place data in the list box in the first place. Thank you all so much and Happy New Year.