HomeActive Query BuilderDrag and drop fields

Drag and drop fields


Hi NG,

Is it possible to Drag and drop fields (with the AQB .NET) from the query window into some other control, lets say a list view. I have seen the Drag and drop that drags fields into AQB , but I want it the other way around. I have seen a product (Profo BI Studio) using you component that is able to do exactly that, so in principle that must be possible

Kind Regards,

Andreas
Andreas | email
February 2 2010, 04:25 PM
Yes, it's possible.

1. Enable drag'n'drop for target control:
listDropTarget.AllowDrop = true;

2. Handle the DragOver event of the target control:

private void listDropTarget_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(DataSourceFieldList)))
{
e.Effect = DragDropEffects.Link;
}
}

3. Handle the DragDrop event of the target control:

private void listDropTarget_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(DataSourceFieldList)))
{
e.Effect = DragDropEffects.Link;

DataSourceFieldList fieldListControl = (DataSourceFieldList) e.Data.GetData(typeof(DataSourceFieldList));

if (fieldListControl.SelectedItem != null)
{
if (((TextAndObject) fieldListControl.SelectedItem).obj != null)
{
MetadataField field = (MetadataField) ((TextAndObject) fieldListControl.SelectedItem).obj;

listDropTarget.Items.Add(field.NameStr + " [" + field.FieldTypeName + "]");
}
}
}
}
Eugene Starkov | email
1 day, 9 hours since original post
This topic is closed