轉(zhuǎn)帖|使用教程|編輯:龔雪|2022-11-04 11:12:04.837|閱讀 191 次
概述:本文將為大家介紹WinForm應(yīng)用實(shí)戰(zhàn)開發(fā)中常見的導(dǎo)航條OutLookBar工具條,歡迎下載相關(guān)推薦工具體驗(yàn)開發(fā)樂趣哦~
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
在很多軟件界面中,一個(gè)好的界面、方便的導(dǎo)航除了為軟件增色不少外,也提高了用戶體驗(yàn),促進(jìn)軟件的良性發(fā)展,因?yàn)槲覀兊能浖话阈枰胁藛巍⒐ぞ邨l、狀態(tài)條等這些基本的東西,但是工具條本身應(yīng)該是一些常用的快捷鍵,內(nèi)容不能放置太多,否則會(huì)容易給客戶凌亂的感覺。菜單條則可以分類,但是好像每次去點(diǎn)擊,一步步深入,則顯得比較麻煩。本文介紹一下一個(gè)很好的導(dǎo)航條OutlookBar控件。
PS:給大家推薦一個(gè)WinForm應(yīng)用界面開發(fā)組件——DevExpress WinForms,它能完美構(gòu)建流暢、美觀且易于使用的應(yīng)用程序,無論是Office風(fēng)格的界面,還是分析處理大批量的業(yè)務(wù)數(shù)據(jù),它都能輕松勝任!
在之前研發(fā)的系統(tǒng)軟件中,都用到了OutLookBar的工具條,使用的界面效果如下所示。
左邊的工具條它們都是同一個(gè)控件來的,控件提供了一種類似Outlook方式的工具條,用來切換各種業(yè)務(wù)窗口,用上這個(gè)控件,肯定為您的程序增色不少。
下面介紹下如何在代碼中使用這個(gè)Outlookbar工具控件。
1. 首先創(chuàng)建一個(gè)窗體,用來放置該控件,由于該控件不是一個(gè)可視化的控件,因此需要做一些特別的處理,如添加一個(gè)ImageList控件,并把OutlookBar控件中用到的圖標(biāo)加載進(jìn)來,記得選擇一些好看的圖片哦。
2. 在MainToolWindow窗體的構(gòu)造函數(shù)或者Load事件中添加OutlookBar的初始化代碼和設(shè)置代碼,如下所示。
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("今日盤點(diǎn)", 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 產(chǎn)品庫存管理 OutlookBarBand mystorageBand = new OutlookBarBand("產(chǎn)品庫存管理"); mystorageBand.SmallImageList = this.imageList; mystorageBand.LargeImageList = this.imageList; mystorageBand.Items.Add(new OutlookBarItem("產(chǎn)品管理", 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 產(chǎn)品庫存管理 case "產(chǎn)品管理": Portal.gc.MainDialog.ShowContent("產(chǎn)品管理", 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); }
在代碼中注意綁定相關(guān)項(xiàng)目的圖標(biāo)序號(hào),否則如果序號(hào)不正確,可能會(huì)出錯(cuò)的,其實(shí)整個(gè)控件就是提供展示一些圖標(biāo),并用同一的事件對(duì)鼠標(biāo)的事件進(jìn)行處理,用戶根據(jù)OutlookBarItem的文本內(nèi)容來判斷處理,雖然模式有點(diǎn)落后,不過個(gè)人感覺控件還是非常好用,方便。
最后呈上相關(guān)的控件文件:
本文轉(zhuǎn)載自:
DevExpress技術(shù)交流群6:600715373 歡迎一起進(jìn)群討論
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: