receiving drag-n-drop from PivotTable field list

F

FurmanGG

I'm able to receive drag-n-drop from the PivotTable field list. However, the
data I get on the drop event is a MemoryStream with 12 bytes. See the code
below for an example of the byte array.

What is that drop data? How can I interpret it or load it into the
appropriate structure or detect which field was dropped?

private void txtCalcFormula_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}

private void txtCalcFormula_DragDrop(object sender, DragEventArgs e)
{
try
{
e.Effect = DragDropEffects.All;
if (e.Data is System.Windows.Forms.DataObject)
{
string sFormat = "Excel_Pivot_Table_Fieldlist_Format";
DataObject dataObj = (DataObject)e.Data;
if (e.Data.GetDataPresent(sFormat))
{
//receives a MemoryStream which is 12 bytes similar
to:
//4 144 97 9 215 0 0 0 228 60 0 0
System.IO.MemoryStream stream =
e.Data.GetData(sFormat) as System.IO.MemoryStream;
StringBuilder sb = new StringBuilder();
foreach (byte b in stream.ToArray())
{
sb.Append((int)b).Append(" ");
}
stream.Close();
MessageBox.Show(sb.ToString());
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
}
}
 

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