ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   receiving drag-n-drop from PivotTable field list (https://www.excelbanter.com/excel-programming/407635-receiving-drag-n-drop-pivottable-field-list.html)

FurmanGG

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


All times are GMT +1. The time now is 02:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com