drag and drop of items between listboxes

S

Sam

Hi,
I've done the method described here :
http://64.78.52.104/FAQ/WinForms/FAQ_c87c.asp#q565q

It works well for items added at design time. However if my source list
is filled with a datasource, the items are properly displayed but the
method


private void OnDragEnter(object sender,
System.Windows.Forms.DragEventArgs e)

{
if (e.Data.GetDataPresent(DataFormats.Text) && !isDropSource )

e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
doesn't work anymore as GetDataPresent returns always False.

Someone can help ?

Thx
 
S

Sam

But that's exactely what I'm doing as described in the link I gave
above.
The issue is that it doesn't seem to work with listbox which data has
been loaded via a datasource(in opposition to loading the data at
design time)
 
C

Cor Ligthert

Sam,

I would be suprised if it was in another way.

You have told that the listbox uses as datasource. What is probably a
datatable (or a view to it) or a list with is filled with objects from a
special class. Let assume it is a datatable. Than you have told to the
listbox that it has to use from maybe 100 items in the datacolumn colection
a certain column.

You drag one item in it in it.
What should it than do?
Create a new datarow
Give that a primary key (little bit funny when it is not an
autoidentifier)
Set the displaymember to a value
Leave 99 columns blank.

Or had you something else in mind I think that there are endless
posibilities.

The items collection in a listbox is seperated from the datasource. In fact
are it two type controls in one. And you wrote it alreaydy drag and drop of
items.

Just my thought,

Cor
 
S

Sam

Cor,

hummm.. I don't understand your message, sorry.
My first list is filled with a datasource (actually it's a dataview, to
answer your question ;-)). Then I drag n drop an item to the second
list. To me once the first list has been filled in, the items inside
are just ... well, items ! So I don't see the difference whether the
list has been filled at design time (hard coded values) or via a
datasource, as the content is still text. Am I missing something ?
 
S

Sam

Ok, I understande. How can I implement drag and drop between two lists
then in that case ? It seems a bit hard and pointless actually as I'm
doing the transfer via double click now and it works much better and
it's more user friendly)

Thx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top