下面的示例代码接管了 TreeList.ShowTreeListMenu 事件,以便于实现下述两个目的。

C#CopyCode image复制代码
using DevExpress.XtraTreeList;

private void treeList1_ShowTreeListMenu(object sender, TreeListMenuEventArgs e) {
   TreeListHitInfo hitInfo = treeList1.CalcHitInfo(e.Point);
         
   // prohibiting summary footer menu for the "Department" column
   if (hitInfo.HitInfoType == HitInfoType.SummaryFooter && 
     hitInfo.Column.Caption == "Department") 
      e.Allow = false;
         
   // removing the "Runtime columns customization" item of the column header menu
   if (hitInfo.HitInfoType == HitInfoType.Column)
      e.Menu.Items.RemoveAt(3);
}

Visual BasicCopyCode image复制代码
Imports DevExpress.XtraTreeList

Private Sub TreeList1_ShowTreeListMenu(ByVal sender As Object, _
ByVal e As TreeListMenuEventArgs) Handles TreeList1.ShowTreeListMenu
   Dim HitInfo As TreeListHitInfo = TreeList1.CalcHitInfo(e.Point)

   ' prohibiting summary footer menu for the "Department" column
   If HitInfo.HitInfoType = HitInfoType.SummaryFooter _
     And HitInfo.Column.Caption = "Department" Then
      e.Allow = False
   End If

   ' removing the "Runtime columns customization" item of the column header menu
   If HitInfo.HitInfoType = HitInfoType.Column Then
      e.Menu.Items.RemoveAt(3)
   End If
End Sub