TAdvSmoothListBox & DragDrop

Hello,

I would like to move one item to another position directly in the code.
With TListBox components, I used the method Move (source, target). I didn't find anything similar in TAdvSmoothListBox, although, there is a method called DragDrop (TObject*,int,int) which could be even more useful.

When I tried it, I expected the same behaviour as I get with the mouse, but unfortunatly It doesn't do this. In fact, I don't know what it does.

Could you explain me its parameters and if it fits for my purpose?

thank you,

If you change the Index of the item to the new position it should work:

  AdvSmoothListBox1.Items.BeginUpdate;
  AdvSmoothListBox1.Items[0].Index := 10;
  AdvSmoothListBox1.Items.EndUpdate;

Kind Regards, 
Scheldeman Pieter

Thanks,

However, when I assign the index I don't see the change applied to the object until I click over it.
I tried to call the methods Refresh() or Repaint() after it without success.
What should I do in order to update the list of items automatically?

thanks,

Did you use the BeginUpdate / EndUpdate calls?

Sorry I didn't realize,
Now it works the movement of the item! But, If I select item 1 (SelectedItemIndex= 1 and the focus is on it) and I move it to position 2 (SelectedItemIndex = 2 but the focus is still in the item 1). So, SelectedItemIndex doesn't point to the item with focus.
My SelectionMode = sPersistSelection and MultiSelect = false.

Dragging & Drop the items with the mouse works fine,
What did I do wrong?

Thanks,

The index does not change, it remains selecteditemindex = 1, this is for maximum flexibility for the developer.


After changing the ItemIndex set the SelectedItemIndex to the Item.index After the EndUpdate call.

At least it isn't what I obserse in my code (C++ Builider 2009)
/
   //i.e: CurrentIndex = 0 & NextIndex = 1
   //Here AdvListBoxSelected->SelectedItemIndex is 0 and the focus is in the index 0
   AdvListBoxSelected->Items->BeginUpdate();
   AdvListBoxSelected->Items->Items[CurrentIndex]->Index = NextIndex;
   AdvListBoxSelected->Items->EndUpdate();
   //Here AdvListBoxSelected->SelectedItemIndex is 1 but the focus is the index 0
/
The focused item remains at the same index but not the SelectedItemIndex.
Even forcing with an explicit it doesn't work: AdvListBoxSelected->SelectedItemIndex = NextIndex;

thanks for helping!




The focus indeed remains on the last selected item. We will investigate if we can make a focused item property available.


Regards, 
Scheldeman Pieter