How to get a cell's name in listbox

How do I get the cell or rows name that is highlighted in a listbox? Other post here have recommended using CELLCLICK and a variable, but what do I assign the variable to?

I can’t seem to find anything like row.name, cell.name, etc…

Not sure what to assign he variable to.

Row and Column are given in the Cell Click event.

If the user clicks the 2nd row of cells and the 3rd cell over
Row = 1
Column = 2
Dim p As Realbasic.Point
p = New Realbasic.Point(Row, Column)

p.X //will = 1
p.Y //will = 2

I’m not following you.

I’m looking to assign the name of the row to a variable. (there are no cells in my listbox)

If you are referring to the cell content:

Get:

Dim cellName as string cellName = listbox.cell(row,column)

Set:

listbox.cell(row,column)="Something"

Rows and Columns do not have names they have numbers and they are already given to you. If you want to fake a name for a row use the rowtag then you can search the rowtags until you find it. But you need a row in order to set the rowtag to something

[quote=126713:@Christoph De Vocht]If you are referring to the cell content:

Get:

Dim cellName as string cellName = listbox.cell(row,column)

Set:

listbox.cell(row,column)="Something"

That doesn’t work. It says cell doesn’t exist.

Let me start over, as I think there is some confusion.

I have a listbox with three rows. They contain the following text: Mike, Ted, Scott.

I want to be able to assign the name (Mike, Ted, or Scott) to a variable based on what row is selected in the listbox.

Then, I have a button below the listbox with the following action:

msgbox variable

So if you click the button, the name (Mike, Ted, or Scott) in the selected row shows up in a msgbox.

That’s all I need. I can take it from there. I’m just having trouble getting started with the piece.

Thanks!

You need to use the CellClick event of the listbox which gives you access to the row & column.

Dim cellName As String cellName = me.cell(row, column)

If you have a listbox that contains Mike, Ted or Scott then
Listbox1.Cell(0,0) = “Mike”
Listbox1.Cell(1,0) = “Ted”
Listbox1.Cell(2,0) = “Scott”

But unless the cell is already there you will get the error saying the cell doesn’t exist.

When the user clicks on Scott the listindex will be 2

In your pushbutton use listindex
msgbox listbox1.Cell(listbox1.listIndex, 0)

Thanks Wayne! That was EXACTLY what I was looking for!