ListBox question

Hi, I am sure there must be a method to find if the user has clicked in a cell which contains text, or if they have clicked in another part of the ListBox which doesn’t contain anything in the row (which of course doesn’t exist yet). But I have played around with the EventHandlers for the ListBox for ages and cannot find a solution.

I have tried this:

selectedRow = row
  If Me.Cell(row, column) = "" Then
    birdDeleteBut.Enabled = False
  Else
    birdDeleteBut.Enabled = True
  End If

This works fine if I click in a cell with text or a cell with not text. But if I click in a row without any text, it doesn’t work. Now I know that is obvious, but I cannot see how to get it to work.

Thanks

Where are you doing this? CellClick only fires on rows that exist… If you want it to fire past that, you will need to do it I’m mousedown

there first do"

Dim Row as Integer = me.RowFromXY(x,y)
Dim Column as Integer = me.ColumnFromXY(x,y)

If either is < 0 then you either clicked past the last row, or in a scrollbar or in the header if they are visible.

  • Karen

Karen

A million thanks! Once I see how it is done, it looks so easy. I knew there had to be a way, and I even looked at the MouseDown/MouseUp Events, but could see how they would help me. I also see how they work now. I guess wherever I click, Xojo gets the x y coordinates (is that relative to the Window bounds) and then Xojo figures out if it is inside the ListBox. I wasn’t sure if I had to figure that out, so I put that in the too hard basket.