View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
FurmanGG FurmanGG is offline
external usenet poster
 
Posts: 4
Default receiving drag-n-drop from PivotTable field list

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);
}
}