2015-05-26 29 views
0

這是怎麼回事,我有一個imagePanel(U可以看看它作爲一個picturePanel) 稱爲imagePanel1(我進口的,所以我不必做滾動條:))如何讓我的面板移動?

和我有一個TreeView左側,從巫婆我可以拖動一個節點,並將其放在imagePanel上,在那裏我得到一個位置的下降,並在該位置我創建一個正常的面板稱爲panel1 所以我做了100次,所以在最後我會有一個完整的小面板imagePanel ... 現在的問題,當我點擊imagePanel(面板所在的地方) 我想要在MousePress上選擇該面板,並在mouseMove上移動,並最終LAY刪除了btn刪除...

以下是imagePanel的代碼: // ************************************* **********************************

private void imagePanel1_DragDrop_1(object sender, DragEventArgs e) 
    { 
     Type testTip = new TreeNode().GetType(); 
     YLScsImage.ImagePanel dropPicturePanel = (YLScsImage.ImagePanel)sender; 
     TreeNode movedNode; 
     _mouseDownSelectedWindow = Rectangle.Empty; 
     if (e.Data.GetDataPresent(testtype)) 
     { 
      movedNode= (TreeNode)e.Data.GetData(testType); 
      dropPicturePanel.Tag = movedNode.Tag; 

      movedNode.ImageIndex = 1; 
      movedNode.SelectedImageIndex = 1; 
      movedNode.ForeColor = Color.Gray; 


//************************************** 
//HERE IS THE CODE FOR THE CREATED PANEL 

      Panel panel1 = new Panel(); 
      Point point1 = this.PointToClient(new Point(e.X - 278, e.Y - 19)); //the imagePanel1 is on the form at the point 278,19 

      panel1.AllowDrop = true; 
      panel1.Location = point1; 
      panel1.BackgroundImage = iltest.Images[0]; //nvm 
      panel1.Height = 16; 
      panel1.Width = 16; 
      imagePanel1.Controls.Add(panel1); //am adding it to the imagePanel1 


    //saving the locations of each panel 
      string path = @"C:\Users\Cosic\Desktop\ICR\TABELA3_Paneli.txt"; // path to file 
      if (!File.Exists(path)) 
       File.Create(path); 
      if (panelBr == 0) 
       System.IO.File.WriteAllBytes(path, new byte[0]); //brise ceo text iz fajla 

      TextWriter sw = new StreamWriter(path, true); 
      sw.WriteLine(e.X + "; " + e.Y + "; " + panel1.Width + "; " + panel1.Height + ";"); 
      sw.Close(); 
    //am done with saving 
      panelBr++;//nvm 

     } 
    } 

告訴我你是否需要更多的代碼。 ..我得到了很多它;) 和英語不好對不起,我不是那麼好,因爲我想成爲......

+0

有沒有一種方法可以附加GUI的屏幕截圖?其他人可能會明白,但是我在頭腦中想象着你的圖形界面特別困難。 – Adam

+0

歡迎來到Stack Overflow!我編輯過你的標題。請參閱:「[應該在其標題中包含」標籤「](http://meta.stackexchange.com/questions/19190/)」,其中的共識是「不,他們不應該」。 –

+0

sry爲標題...但我不能發佈圖像,我需要10個repurtations來做到這一點...這裏是描述:在左側角落是一個叫做tView的treeView,在右側角落是imagePanel,叫做imagePanel1並有ra更改按鈕的背景,並退出按鈕,這就是我解決它的所有 – Stefan

回答

0

我解決了這個問題,像這樣的:

panel1.MouseUp += new MouseEventHandler(panel1_MouseUp); 

剛寫panel1.anyEventUWant + =和2次選項卡按鈕.... 它全自動生成與它

這裏一個單一代碼行新的功能是一個示例

void panel1_MouseUp (object sender, EventArgs e)     
{   
    //throw new NotImplementedException();  
} 

U能夠訪問面板是這樣的:((對象)發送方)。