About   -   Contact   -   Purchase   -   Search   -   What's New

Drag and Drop in a List Box
This tip was sent in by Sammy Peoples.

This is one of those tips that needs careful thought before use:

First of all this is not defined behavior for a listbox and really you should not add things like this to standard controls as you are violating the whole point of a standard user interface.

I would suggest you build your own custom user object that has similar functionality to a ListBox using a datawindow would be my approach. Then provide a different looking control to drop down the list i.e. not the std windows controls. You could then use standard PB Datawindow functions to do the drag and drop functionality.

User is trying to do drag drop within the same ListBox.


Declare user event in listbox "ue_ldown" mapped to pbm_lbuttondown
Declare user eventin listbox "ue_lup" mapped to pbm_lbuttonup
Declare user event in listbox "ue_getselect" mapped to pbm_custom01
Declare user event in listbox "ue_insert" mapped to pbm_custom02

Create instance variables.. integer sel_index, string sel_text

In the user event ue_ldown code... Postevent("ue_getselect")

In the user event ue_getselect code...


In the user event ue_lup code... Postevent("ue_insert")

In the user event ue_insert code...

int dropitem

* Note: Make sure the Sort checkbox is not selected for the ListBox!!


Top of Page

Legal Notice

Ken Howe 2011