Control In Listbox

I am probably getting confused with another language but thought there was a way to get other controls to sit inside a cell in a listbox? Did I imagine that?!

I want the last cell in each row to have a delete button instead of text saying delete if that makes sense?

Add a menuItem (Delete) with a Keyboard shortcut, Add a Menu Handler and Populate the Menu Handler with code, then the user is able to select/delete each, any Row at will.

Thanks Emile but I’m not struggling to find an alternative way, I already have a way to do it, I just wanted to put a button in the listbox and there have been other times I’ve wanted to put controls in a listbox too.

I guess it just can’t be done.

No, it can be done, excepted I’ve done the way I wrote above. *

Your project, your will.

Look there:

http://documentation.xojo.com/api/deprecated/listbox.html#listbox-columntypeat

and follow your way (make more search to find what you want).

  • The problem I have with what you want to implement is the empty row(s) here and there. But as I wrote earlier: your software.

Edit II:
http://documentation.xojo.com/api/deprecated/listbox.html#listbox-celltypes

Now, you can eventually add an image of a button and use that as a Delete button (with code). But once more, I may be wrong (or not what you really want).

[quote=471227:@Emile Schwarz]No, it can be done, excepted I’ve done the way I wrote above. *

Your project, your will.

Look there:

http://documentation.xojo.com/api/deprecated/listbox.html#listbox-columntypeat

and follow your way (make more search to find what you want).

  • The problem I have with what you want to implement is the empty row(s) here and there. But as I wrote earlier: your software.

Edit II:
http://documentation.xojo.com/api/deprecated/listbox.html#listbox-celltypes

Now, you can eventually add an image of a button and use that as a Delete button (with code). But once more, I may be wrong (or not what you really want).[/quote]

Hi, thanks again for that but my question was can you use other standard controls in a listbox. I think I was getting confused with a language I used on Windows a few years back. Thanks again.

The only one provided is the CheckBox. Read the second link (enum).

And to give you a strick answer: no.

Sorry, stupid question: have-you tried to drop the control you- want to use on a ListBox ?

[quote=471229:@Emile Schwarz]The only one provided is the CheckBox. Read the second link (enum).

And to give you a strick answer: no.[/quote]

Yes, I use the checkbox often. Thanks, thought so. Shame.

Fake it:
use pushButton.drawInto into a picture.graphics;
draw picture in Listbox.cellTextPaint event;

Extra bonus points for getting a pixel perfect image using window.bitmapForCaching and swapping it when the window changes screens.

p.s. pushButton.drawInto directly into listbox.cellTextPaint seems to crash my apps, using a picture is more trouble, but appears more reliable.

I had the same problem, so its not you. DrawInto directly in CellTextPaint always crashes, so use a picture instead.

Another alternative is to roll your own list box using a container control for the list box and one (or more) container controls as your rows.

A quick example here:

https://storage.googleapis.com/charlierobin-1245.appspot.com/downloads/listbox_with_container_control_rows.zip

(Very rough and ready, just to show the general principle of the thing. I have no idea how this looks or behaves on Windows or Linux.)

Of course, with container controls as the basis of a row, you can then have whatever you want on each row of your list.

You might be interested in this article

https://forum.xojo.com/46100-what-can-i-embed-within-a-weblistbox

[quote=471269:@Brock Nash]You might be interested in this article

https://forum.xojo.com/46100-what-can-i-embed-within-a-weblistbox[/quote]

Thanks Brock but I’m talking Desktop not Web.

Theres no way to embed a control in a desktop listbox
At best you could do something like Alex Restrepo’s old code which did custom cells
It works pretty well - but its still not embedding an actual custom control in a listbox cell

[quote=471564:@Norman Palardy]Theres no way to embed a control in a desktop listbox
At best you could do something like Alex Restrepo’s old code which did custom cells
It works pretty well - but its still not embedding an actual custom control in a listbox cell[/quote]

Thanks Norman.

I’ve settled for making the last column a smaller font size with the text in bold, it stands out enough to be obvious to the end user. Can’t quite see why Xojo would add a checkbox and not a button as well, I would imagine it would be a quite requested feature.

1 Like

You can draw an image (small) instead, it will be more obvious.

:wink: