Drag to reorder listbox columns

I would like to allow users to drag listbox columns to reorder them. Any ideas about how to implement this?

There does not appear to be any events from drag and drop of columns however this does sound like the kind of functionality that you should program yourself. You could maybe either have a go at programming your own canvas-based listbox with your customized functionality. This is because the native API controls do not always offer everything you need, so you may need the full flexibility with the power of your own custom-written listbox. You could check out this class from Alex Restrepo:

That may help you with placing your own controls instead a native listbox which may make it easier for you to achieve this.

As for moving the list items from one column to another, keep an array backup of the list items before moving them, then insert them into its new row and replace it with its new list items.

Sorry to leave you left a bit on your own but it would make good practice if you could work this out for yourself, instead of me writing the code for you.

Hope this help

[quote=53993:@Oliver Scott-Brown]There does not appear to be any events from drag and drop of columns however this does sound like the kind of functionality that you should program yourself. You could maybe either have a go at programming your own canvas-based listbox with your customized functionality. This is because the native API controls do not always offer everything you need, so you may need the full flexibility with the power of your own custom-written listbox. You could check out this class from Alex Restrepo:

That may help you with placing your own controls instead a native listbox which may make it easier for you to achieve this.

As for moving the list items from one column to another, keep an array backup of the list items before moving them, then insert them into its new row and replace it with its new list items.

Sorry to leave you left a bit on your own but it would make good practice if you could work this out for yourself, instead of me writing the code for you.

Hope this help[/quote]
Btw you may somehow have to hide the header for the RBCustomCells class (if that is possible, I do not even know). And you can use the first row with your own custom-written headers.

You can achieve this. Im almost there myself.

Basically i did this :-

Create my own column header to replace builtin one
Allow drag an drop between the header elements
Swap the data in each column that swapped

That bit is ‘reasonably’ easy

The problems i have is i have logic that works on the columns to sum col1 +col2
And i needto then refresh the data.

Its achievable though. Good luck

Ross: thank you for the idea.

I considered using a ToolBar with buttons: You set a column value to move, you set a column balue to go (insert before column x), etc.

I will investigate your idea.

Thanks everyone for your ideas. I think I will try Russ’ suggestion or the plugin Jean-Paul mentioned.