Double click to add row to listbox

Hello,
I wish to double click on one of the Listboxes. When double-click I wish to add a new row with a text e.g. Rose. I tried both Double-box and then cellClick

ListboxTodo.AddRow(" Babaji")
ListboxTodo.Selected(me.ListIndex)=True

However, nothing happens when I double click on the Listbox.

Appreciate any guidance.

Thanks

In the LR (http://documentation.xojo.com/Listbox), you will find the answer.

Basically, implement a DoubleClick event (Insert New Event).
Add a Row,
Add whatever text from whatever source (Clipboard, File from disk, constant/variable) into the Cell you want.

Thank you!

Currently I have a textfield and a button. When I click the button it add the test in the textfield into a new row in the Listbox.

Instead of this, Is there a way that I could directly type the item into the listbox?

Thanks!

[quote=448486:@GANESALINGAM NAENTHIRAN]Thank you!

Currently I have a textfield and a button. When I click the button it add the test in the textfield into a new row in the Listbox.

Instead of this, Is there a way that I could directly type the item into the listbox?

Thanks![/quote]

Check http://documentation.xojo.com/api/deprecated/listbox.html.CellType

I do not know what you want to do. Read the Listbox Control definition in the LR and use the correct way to achieve your goal.

In this case, you may want to edit a Cell, if so:

Add a brand new Row on a Click Event (to be added) or DoubleClick Event,
Set the cliked Cell as Active,
Type there what you want, once done, press the Return key (or Tab if you implemented it in your Listbox (to go to the next Cell and make it Editable.

Thank you! This what I was looking for.

How do I make a particular cell in my Listbox Active?

me.Addrow("")
me.cell(me.ListIndex,0)=Activecell
me.CellType(me.ListIndex,0) = ListBox.TypeEditableTextField

Thanks!

RTFM, please :wink:

http://documentation.xojo.com/api/deprecated/listbox.html

[code]Making a Cell Editable

Use the CellType or ColumnType properties to change a cell or column to “inline editable” when you want the user to be able to edit the contents of the ListBox. Then call the EditCell method for each cell. This gives the focus to the editable cell and selects the current text of the cell, if any. Typing replaces the cell’s contents. When the user presses Tab or Return or clicks in another cell, the cell loses the focus and the contents of the cell are saved.

The following code in the CellClick event makes the cell the user clicked on editable. The parameters row, and column are passed to the function.
Me.CellType(row, column) = ListBox.TypeEditable
Me.EditCell(row, column)

When a cell is editable, the ActiveCell property is the TextField that contains the contents of that cell. You can use this property to set or get the text of the Listbox cell, set the selection, or change other properties of the ListBox’s TextField.[/code]

Thanks Emile!
If any consolation, did read the manual numerous times :slight_smile:

Finally got a working solution

In the "Open’ event for the Listbox:
me.addrow
Me.ColumnType(0)=ListBox.TypeEditableTextField

Global variable (property)
theListbox (as a Listbox)

Method: adhoc
theListbox.Addrow("")
theListbox.CellType(theListbox.LastIndex,0) = ListBox.TypeEditableTextField

in the ‘CellAction’ event of the Listbox:
theListbox=me
adhoc(theListbox)

Thanks again! Bw