2014-02-10 31 views
0

我的表單有一個鏈接標籤llInventory和ContextMenuStrip cmsInventory。當我在鏈接標籤上點擊時,上下文菜單欄應該在鏈接標籤的正下方打開。所以我寫的代碼來定位的ContextMenuStrip,但它仍然顯示它在屏幕的左上角,這裏是代碼如何在鏈接標籤下放置ContextMenuStrip?

 private void llInventory_MouseClick(object sender, MouseEventArgs e) 
    { 
     if (e.Button == MouseButtons.Left) 
     { 
      // llInventory.BackColor = Color.Blue; 
      //llInventory.ForeColor = Control. 
      Point p = new Point(this.llInventory.Location.X, this.llInventory.Location.Y + llInventory.Height); 
      cmsInventory.PointToScreen(p); 
      cmsInventory.Show(); 
     } 
    } 

我該如何解決這個問題?

回答

1

你應該使用這個方法Show(Point)

cmsInventory.Show(cmsInventory.PointToScreen(p)); 

或者你可以使用Show(Control, Point)過載相對於指定的控制位置的ContextMenuStrip定位。

+0

show(control,point)works !!! –