Containercontrol in listbox

Can anyone please help me started how to use a container control in a list box as a cell (desktop app)?
An example or refer to a manual would be awesome.

Thanks in advanced.

You cannot put a container in a listbox cell. It is not supported.

However, you can do it yourself but it involves using two to three containers to make your own listbox.

  1. And overall ‘control’ container that containers scrollbars and the logic for viewing.
  2. An optional ‘scrolling’ container that contains your rows. This is optional because you can do the same thing without this just by iterating your ‘row’ containers (see #3).
  3. Your ‘row’ container that has the native controls you want to use.

In item 1 you tell it to add/remove rows and it does the magic of embedding it into the control and figuring out where it goes in the container. There are a number of events you’ll want to add to but that will get you started. It’s relatively complex programming but it will get you going with what I think you’re trying to do.

You cannot add a ContainerControl to a ListBox as a cell or anything else. However, you can draw your own controls in ListBox cells using either CellBackgroundPaint or CellTextPaint.

Refer to the ContainerControl webinar for an example on how to use a ContainerControl to create a list of controls.

I don’t think the above statements are strictly true. I have managed to embed containers within my own list box.

I am not at my main computer just now but will dig out the help file that I created for myself for future projects and publish that shortly.

Simon.

I have now created a small project which incorporates my methods of adding a Container Control to a list box.

You can download all the elements together here: https://dl.dropboxusercontent.com/u/10747116/RealStudioClasses/ContainerControlInListbox.zip

I use these methods extensively in my applications to give smooth scrolling without having to code!

Comments are always welcomed.

Simon.

Impressive, but I don’t think it’s what the OP was looking for.

It works because you’re using DrawInto. Essentially all you’re doing is painting the controls into the cell. The controls that are inside the row container aren’t ‘live’ and don’t respond to events natively. To do that you need to do some more magic behind the scenes.

[quote]Bob Keeney
It works because you’re using DrawInto. Essentially all you’re doing is painting the controls into the cell. The controls that are inside the row container aren’t ‘live’ and don’t respond to events natively. To do that you need to do some more magic behind the scenes.[/quote]

You’re right except… I store a ‘key’ in rowtag which is used upon selection to retrieve the originating data. For all my database apps this works very well.

What you see on screen is a drawn ‘copy’ of the container control and not ‘real’ data but, to the user, that is completely invisible.

In essence I was responding to the responses to the OP that (in my opinion) were a bit knee-jerk in their reaction!

Simon.

Very impressive, but as Bob pointed out not live. Not looking at the code I wanted to enter some text - which you can’t do as it is just a drawing of the control. However you should be able to overlay the containercontrol to allow direct data entry.

[quote=26175:@Markus Winter]Very impressive, but as Bob pointed out not live. Not looking at the code I wanted to enter some text - which you can’t do as it is just a drawing of the control. However you should be able to overlay the containercontrol to allow direct data entry.

[/quote]
For the general case, the trick with that is to make sure the entire cell is visible so the overlay fits. That might require horizontally scrolling on a click in the cell before overlaying the container control

Thanks everyone for your answers and examples, although I hoped it was a lot more easy to make a fancy Listbox with ContainerControls :slight_smile:

I’ll start with Bob’s idea and will also look at the overlays.

Thanks again.

Friends, someone has the example to download.

I never saw this thread in 2013, but did just see your addition. While I can’t point you to the requested example, if you are in need of cells having container controls you might consider a third party alternative to the listbox which does.

Take a look at what is supported by piDog’s DataView

No vested interest myself; I’m just a user of the control.

I have a copy. I put it into my DropBox:

This forum really needs a file ability.

[quote=370003:@Markus Winter]I have a copy. I put it into my DropBox:

https://www.dropbox.com/s/jeg7s7grvqksugi/ContainerControlInListbox.zip?dl=0

This forum really needs a file ability.[/quote]

I agree, it is necessary to keep the links alive.

There is a plugin for esoTalk to do attachments (files, images)