1 向工作區拖入一個DevExpress.XtraBas.Barmanager控件,拖入一個DevExpress.XtraBas.PopupMenu控件。
2 PopupMenu控件設定Manager屬性是剛才拖入的Barmanager名稱,在PopupMenu控件右擊設定“Customise”,設定具體菜單
3 樹右擊菜單的代碼
/// <summary>
/// 右擊節點出現的菜單
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void treeDistrictInfo_MouseUp(object sender, MouseEventArgs e)
{
TreeList tree = sender as TreeList;
if ((e.Button == MouseButtons.Right) && (ModifierKeys == Keys.None)
&& (treeDistrictInfo.State == TreeListState.Regular))
{
Point p = new Point(Cursor.Position.X, Cursor.Position.Y);
TreeListHitInfo hitInfo = tree.CalcHitInfo(e.Location);
if (hitInfo.HitInfoType == HitInfoType.Cell)
{
tree.SetFocusedNode(hitInfo.Node);
popupMenu1.ShowPopup(p);
}
}
}