0
private void treeView_ItemDrag(object sender, ItemDragEventArgs e)
{
try
{
IVariable variable = getSelectedNode();
this.treeView.DoDragDrop((Variable)variable, DragDropEffects.Copy);
}
catch (Exception) { }
}
private void splitContainer_Panel2_DragDrop(object sender, DragEventArgs e)
{
Variable var = (Variable)(e.Data);
}
變量是一個變量對象(單例模式)。我想把這個對象從一個樹視圖拖到另一個視圖(繪製對象)。 我得到這個錯誤代碼:如何用C#拖動任何對象? (Wrapping)
類型的對象「System.Windows.Forms.DataObject」不能轉換爲類型「ORANGE_VARIABLE.Variable」
我裏面有正確的對象該data.form。
我怎樣才能解開這個對象?
謝謝!它的工作 – Thomas 2012-03-13 08:18:34