轉帖|使用教程|編輯:龔雪|2022-11-04 11:12:04.837|閱讀 191 次
概述:本文將為大家介紹WinForm應用實戰開發中常見的導航條OutLookBar工具條,歡迎下載相關推薦工具體驗開發樂趣哦~
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
在很多軟件界面中,一個好的界面、方便的導航除了為軟件增色不少外,也提高了用戶體驗,促進軟件的良性發展,因為我們的軟件一般需要有菜單、工具條、狀態條等這些基本的東西,但是工具條本身應該是一些常用的快捷鍵,內容不能放置太多,否則會容易給客戶凌亂的感覺。菜單條則可以分類,但是好像每次去點擊,一步步深入,則顯得比較麻煩。本文介紹一下一個很好的導航條OutlookBar控件。
PS:給大家推薦一個WinForm應用界面開發組件——DevExpress WinForms,它能完美構建流暢、美觀且易于使用的應用程序,無論是Office風格的界面,還是分析處理大批量的業務數據,它都能輕松勝任!
在之前研發的系統軟件中,都用到了OutLookBar的工具條,使用的界面效果如下所示。
左邊的工具條它們都是同一個控件來的,控件提供了一種類似Outlook方式的工具條,用來切換各種業務窗口,用上這個控件,肯定為您的程序增色不少。
下面介紹下如何在代碼中使用這個Outlookbar工具控件。
1. 首先創建一個窗體,用來放置該控件,由于該控件不是一個可視化的控件,因此需要做一些特別的處理,如添加一個ImageList控件,并把OutlookBar控件中用到的圖標加載進來,記得選擇一些好看的圖片哦。
2. 在MainToolWindow窗體的構造函數或者Load事件中添加OutlookBar的初始化代碼和設置代碼,如下所示。
private OutlookBar outlookBar1 = null; public MainToolWindow() { InitializeComponent(); InitializeOutlookbar(); } private void InitializeOutlookbar() { outlookBar1 = new OutlookBar(); #region 銷售管理 OutlookBarBand outlookShortcutsBand = new OutlookBarBand("銷售管理"); outlookShortcutsBand.SmallImageList = this.imageList; outlookShortcutsBand.LargeImageList = this.imageList; outlookShortcutsBand.Items.Add(new OutlookBarItem("訂單管理", 0)); outlookShortcutsBand.Items.Add(new OutlookBarItem("客戶管理", 1)); outlookShortcutsBand.Items.Add(new OutlookBarItem("水票管理", 2)); outlookShortcutsBand.Items.Add(new OutlookBarItem("套餐管理", 3)); outlookShortcutsBand.Items.Add(new OutlookBarItem("今日盤點", 5)); outlookShortcutsBand.Items.Add(new OutlookBarItem("來電記錄", 6)); outlookShortcutsBand.Items.Add(new OutlookBarItem("送貨記錄", 7)); outlookShortcutsBand.Background = SystemColors.AppWorkspace; outlookShortcutsBand.TextColor = Color.White; outlookBar1.Bands.Add(outlookShortcutsBand); #endregion #region 產品庫存管理 OutlookBarBand mystorageBand = new OutlookBarBand("產品庫存管理"); mystorageBand.SmallImageList = this.imageList; mystorageBand.LargeImageList = this.imageList; mystorageBand.Items.Add(new OutlookBarItem("產品管理", 2)); mystorageBand.Items.Add(new OutlookBarItem("庫存管理", 3)); mystorageBand.Background = SystemColors.AppWorkspace; mystorageBand.TextColor = Color.White; outlookBar1.Bands.Add(mystorageBand); #endregion . outlookBar1.Dock = DockStyle.Fill; outlookBar1.SetCurrentBand(0); outlookBar1.ItemClicked += new OutlookBarItemClickedHandler(OnOutlookBarItemClicked); outlookBar1.ItemDropped += new OutlookBarItemDroppedHandler(OnOutlookBarItemDropped); //outlookBar1.FlatArrowButtons = true; this.panel1.Controls.AddRange(new Control[] { outlookBar1 }); } private void OnOutlookBarItemClicked(OutlookBarBand band, OutlookBarItem item) { switch (item.Text) { #region 銷售管理 case "訂單管理": Portal.gc.MainDialog.ShowContent("訂單管理", typeof(FrmOrder)); break; case "客戶管理": Portal.gc.MainDialog.ShowContent("客戶管理", typeof(FrmCustomer)); break; case "水票管理": Portal.gc.MainDialog.ShowContent("水票管理", typeof(FrmTicketHistory)); break; case "套餐管理": FrmYouhui dlg = new FrmYouhui(); dlg.ShowDialog(); break; case "來電記錄": Portal.gc.MainDialog.ShowContent("來電記錄", typeof(FrmComingCall)); break; case "送貨記錄": Portal.gc.MainDialog.ShowContent("送貨記錄", typeof(FrmDeliving)); break; #endregion #region 產品庫存管理 case "產品管理": Portal.gc.MainDialog.ShowContent("產品管理", typeof(FrmProduct)); break; case "庫存管理": Portal.gc.MainDialog.ShowContent("庫存管理", typeof(FrmStock)); break; #endregion .. default: break; } } private void OnOutlookBarItemDropped(OutlookBarBand band, OutlookBarItem item) { // string message = "Item : " + item.Text + " was dropped"; // MessageBox.Show(message); }
在代碼中注意綁定相關項目的圖標序號,否則如果序號不正確,可能會出錯的,其實整個控件就是提供展示一些圖標,并用同一的事件對鼠標的事件進行處理,用戶根據OutlookBarItem的文本內容來判斷處理,雖然模式有點落后,不過個人感覺控件還是非常好用,方便。
最后呈上相關的控件文件:
本文轉載自:
DevExpress技術交流群6:600715373 歡迎一起進群討論
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: