1. 程式人生 > >Devexpress TreeList 屬性設定

Devexpress TreeList 屬性設定

            //tvwMonitorTree.OptionsView.AutoWidth = false; //禁用自動寬度
            //tvwMonitorTree.Columns["stateName"].Width = 180; //設定指定列寬
            //tvwMonitorTree.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
            //預設顯示下拉三角形樣式,設定TreeList的兩個面板屬性即可變成連線虛線
            tvwMonitorTree.LookAndFeel.UseDefaultLookAndFeel = false;
            tvwMonitorTree.LookAndFeel.UseWindowsXPTheme = true;

            tvwMonitorTree.OptionsView.ShowHorzLines = false; //是否顯示水平線。預設為True;
            tvwMonitorTree.OptionsView.ShowVertLines = true; //是否顯示垂直線。預設為True;
            tvwMonitorTree.OptionsView.ShowIndicator = false; //是否顯示Node的指示符面板,就是最左邊有個三角箭頭。預設為True;
            tvwMonitorTree.OptionsView.ShowButtons = true; //是否顯示展開與收縮按鈕。預設為True;
            tvwMonitorTree.OptionsView.ShowColumns = false; //是否顯示列標題。預設為True;
            tvwMonitorTree.OptionsView.ShowIndentAsRowStyle = false; //是否用相應Node的Appearance設定來生成Tree的縮排(沒看懂)。預設為False
            tvwMonitorTree.OptionsView.FocusRectStyle = DevExpress.XtraTreeList.DrawFocusRectStyle.None; //在獲得焦點的Cell上,是否顯示焦點框架。預設為True;
            //tvwMonitorTree.OptionsView.FocusRectStyle = DrawFocusRectStyle.CellFocus;
            tvwMonitorTree.OptionsView.ShowRoot = true; //是否在根Node間顯示連線線。預設為True;
            tvwMonitorTree.OptionsView.ShowCheckBoxes = false; //顯示勾選框。預設為False
            tvwMonitorTree.OptionsDragAndDrop.DragNodesMode = DragNodesMode.None;//拖拽節點
            tvwMonitorTree.OptionsBehavior.ReadOnly = true; //只讀
            tvwMonitorTree.OptionsBehavior.Editable = false; //不可編輯
            tvwMonitorTree.OptionsBehavior.AllowIndeterminateCheckState = true; //設定節點是否有中間狀態,即一部分子節點選中,一部分子節點沒有選中
            tvwMonitorTree.OptionsSelection.InvertSelection = true; //選中風格是隻應用於選中的Cell
            tvwMonitorTree.OptionsSelection.MultiSelect = false; //允許多選
            tvwMonitorTree.OptionsSelection.EnableAppearanceFocusedCell = true; //選中的Cell的Appearance設定是否可用
            tvwMonitorTree.ExpandAll(); //展開所有層級
            // tvwMonitorTree.ExpandToLevel(0); //展開的層級

            ////註冊這兩個事件實現選擇父節點自動選子節點,反之亦然
            //tvwMonitorTree.BeforeCheckNode += tvwMonitorTree_BeforeCheckNode;
            //tvwMonitorTree.AfterCheckNode += tvwMonitorTree_AfterCheckNode;

            //tvwMonitorTree.AfterFocusNode += tvwMonitorTree_AfterFocusNode;
            //tvwMonitorTree.DoubleClick += tvwMonitorTree_DoubleClick; //但要注意的是要在TreeList.OptionsBehavior.Editable = false的情況下,雙擊Node才能觸發該事件
            ////設定圖片
            //// tvwMonitorTree.CustomDrawNodeImages += tvwMonitorTree_CustomDrawNodeImages;
            //// 顏色設定
            ////tvwMonitorTree.Appearance.Row.BackColor = Color.Transparent;//節點預設背景色
            ////  tvwMonitorTree.Appearance.FocusedRow.BackColor = Color.Orange; // 選中節點的背景色
            ////  tvwMonitorTree.Appearance.HideSelectionRow.BackColor = Color.LightYellow;//選中節點失去焦點時的背景色