2014-10-02 698 views
0

我有以下問題。我希望TreeList中選定的NodeCell周圍的虛線邊框包裹整行,而不是單擊我單擊的單元格。行的選擇是好的(即整個行被選中,不管哪個單元格被聚焦),但是我希望邊框突出顯示整行,而不是單擊該行內的特定單元格。我已經設置:在TreeList中選擇整行時設置邊框DevExpress

treeList.OptionsSelection.EnableAppearanceFocusedCell = false; 

但似乎我需要的TreeList一個屬性,它類似於一個GridView控件,如:

gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus; 

我連着截圖舉例:

enter image description here

所選行以藍色突出顯示(正確),但邊框突出顯示特定單元格,但實際上已選擇整行。我希望邊框包裹整行,而不僅僅是一個單元格。

回答

1

DevExpress support forum - 目前XtraTree中沒有相當於FocusRectStyle

但是,如果您需要虛線邊框 - 您可以自行繪製。

首先,設置treeList.OptionsSelection.EnableAppearanceFocusedCell = false;

接下來,你想不想找個地方畫你的邊界在類中定義的筆:

private readonly Pen _PenBorder = new Pen(Color.Black) {DashStyle = DashStyle.Dot}; 

最後,通過這樣的處理treeList.CustomDrawNodeCell事件:

void TreeListCustomDrawNodeCell(object sender, CustomDrawNodeCellEventArgs e) 
{ 
    if (e.Node.Focused) 
    { 
     e.Graphics.DrawLine(_PenBorder, e.Bounds.Left, e.Bounds.Top, e.Bounds.Right, e.Bounds.Top); 
     e.Graphics.DrawLine(_PenBorder, e.Bounds.Left, e.Bounds.Bottom - 1, e.Bounds.Right, e.Bounds.Bottom - 1); 

     if (e.Column.VisibleIndex == 0) 
      e.Graphics.DrawLine(_PenBorder, e.Bounds.Left, e.Bounds.Top, e.Bounds.Left, e.Bounds.Bottom); 

     if (e.Column.VisibleIndex == treeList.VisibleColumns.Count - 1) 
      e.Graphics.DrawLine(_PenBorder, e.Bounds.Right - 1, e.Bounds.Top, e.Bounds.Right - 1, e.Bounds.Bottom); 
    } 
} 
+0

是的,我想這將是一個解決方案,但我希望有一些「便宜」。無論如何,感謝您的建議,我會嘗試一下,看看它是如何發展的 – 2014-10-02 12:22:32