PDA

View Full Version : Sorting items in a multi-column listbox



avadhutd2
12-01-2009, 03:37 AM
Hi,

I have a query about Multi-Column Listbox property. There are 3 columns in the listboxes that I use.

The column no 3 in my listboxes is a ColID field which is numeric - like 1, 2, 3 ....

Just to give you some picture...The Multi-Column Listbox may look like:

Col1 Col2 Col3(ColID)
Item1 Typ1 1
Item2 Typ2 2
Item3 Typ3 3

While fetching from database I populate the data using SQL Query in the listbox1 with order of ColID field in ascending manner.

Next I use the entries in listbox1 to get transferred to listbox2. (For example item# 1 in the listbox 1 which has a ColId as 1 transferred to listbox2 using a button).

Now when I transfer back the same item back to listbox1 I get that added to listbox1 but not at the same place as it was earlier.

Is there any way that we can sort the items in a listbox in ascending manner by a column?

For example - in my case I need to always sort listbox1 by column# 3 (ColID) as I need the items arranged for ColID in order 1, 2, 3 ....etc

Kindly let me know...

Thanks!

xld
12-01-2009, 04:35 AM
This is how I would do it.

When I populate the listbox, I would add a further column, not showing, with shows the index number. When transferring it to Listbox 2, take that extr column across too. When you re-instate it, you can slot it back where it came from.