轉(zhuǎn)帖|使用教程|編輯:鮑佳佳|2020-07-31 11:45:10.080|閱讀 324 次
概述:本文主要是對codejock的comandbar的具體操作步驟流程進行了詳細的介紹。在文末附上了詳細的代碼解析教程。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Codejock 軟件的Xtreme Command Bars 提供非常漂亮的Office風格的命令條和One Note樣式的Tab. 這種構(gòu)架完全支持菜單和工具欄的個性化設(shè)置, 它將在應(yīng)用程序工作臺上給你更大的控制權(quán), Xtreme Command Bars提供嵌入式主題支持,允許你選擇預(yù)先定義的主題如Officexp、Office 2003、 Visual Studio .NET,或者自定義主題。它是Xtreme Suite的一部分。
CommandBar Action消除了使用Update事件來更新\更改在菜單和工具欄中出現(xiàn)多個位置的項目的狀態(tài)和屬性的需要。例如,您可能有一個菜單項也出現(xiàn)在工具欄中,那么用戶可能已經(jīng)創(chuàng)建了相同的按鈕,并將其放置在用戶創(chuàng)建的工具欄中。使用“Actions”,您可以簡單地修改項目的操作,無論用戶添加了多少用戶,它都會更新所有出現(xiàn)的項目。
操作對于本地化也很有用,因為您可以為每個本地設(shè)置一組操作,這些操作可以輕松用于更新所有出現(xiàn)的項目,以確保所有項目都得到更新。
具體操作:
每個CommandBar項都有一個ID。然后,具有相同ID的項目可以共享一組公共屬性。CommandBars Action對象(在下圖中表示為“ Item Actions”)是一組指定ID的所有項目都可以共享的屬性。添加操作時,您將指定操作的ID,標題,工具提示文本,描述文本和類別。Id是您將分配給CommandBar項目的ID,您無法使用操作的屬性。現(xiàn)在,任何與動作具有相同ID的CommandBar項都將使用該動作的屬性。更新操作的任何屬性時,無論用戶添加了多少(在彈出菜單中還是在工具欄中),它將自動更新所有出現(xiàn)的項目。
該EnableActions必須調(diào)用方法,以使操作能夠使用。每個CommandBar項都有一個Action屬性,該屬性只是對與其關(guān)聯(lián)的CommandBars Action項的引用。如果沒有為項目添加任何操作或尚未啟用操作,則將使用該項目的默認屬性。
在下圖中,“菜Menu Item”,“Toolbar Item”和“User Customized Item (user created toolbar)都共享相同的“Item Action”。修改操作的屬性時,它將更新所有出現(xiàn)的項目。
'Constants used to identify controls Const ID_FILE_NEW = 100 Const ID_FILE_OPEN = 101 Const ID_FILE_CLOSE = 102 Const ID_FILE_SAVE = 103 Const ID_FILE_EXIT = 104 Const ID_FILE_PRINT = 113 Const ID_FILE_PRINT_SETUP = 114 Private Sub Form_Load() 'Enable the use of actions CommandBars.EnableActions 'Create Actions to be used by CommandBar items. You can create 'the action before or after the CommandBar Items are added, but 'if you create them before like this sample be sure not to 'overwrite any of the 5 properties of the actions when the 'CommandBar item is added. CommandBars.Actions.Add ID_FILE_NEW, "&New", "New", _ "Create a new document", "File" CommandBars.Actions.Add ID_FILE_OPEN, "&Open", "Open", _ "Open an existing document", "File" CommandBars.Actions.Add ID_FILE_SAVE, "&Save", "Save", _ "Save the active document", "File" CommandBars.Actions.Add ID_FILE_PRINT, "&Print", "Print", _ "Print the active document", "File" CommandBars.Actions.Add ID_FILE_PRINT_SETUP, "&Print Setup", _ "Print Setup", "Change the printing options", "File" CommandBars.Actions.Add ID_FILE_CLOSE, "&Close", "Close", _ "Close the active document", "File" CommandBars.Actions.Add ID_FILE_EXIT, "&Exit", "Exit", _ "Quit the application; prompts to save documents", "File" Dim Control As CommandBarControl Dim ControlFile As CommandBarPopup 'Add some CommandBar items. Set ControlFile = CommandBars.ActiveMenuBar.Controls.Add( _ xtpControlPopup, 0, "&File") With ControlFile.CommandBar.Controls .Add xtpControlButton, ID_FILE_NEW, "" .Add xtpControlButton, ID_FILE_OPEN, "" .Add xtpControlButton, ID_FILE_SAVE, "" Set Control = .Add(xtpControlButton, ID_FILE_PRINT, "") Control.BeginGroup = True .Add xtpControlButton, ID_FILE_PRINT_SETUP, "" Set Control = .Add(xtpControlButton, ID_FILE_EXIT, "") Control.BeginGroup = True End With Dim ToolBar As CommandBar Set ToolBar = CommandBars.Add("Standard", xtpBarTop) With ToolBar.Controls .Add xtpControlButton, ID_FILE_NEW, "" .Add xtpControlButton, ID_FILE_OPEN, "" .Add xtpControlButton, ID_FILE_SAVE, "" Set Control = .Add(xtpControlButton, ID_FILE_PRINT, "") Control.BeginGroup = True End With 'Disable ALL items with Id ID_FILE_SAVE CommandBars.Actions(ID_FILE_SAVE).Enabled = False 'Change the Caption of ALL items with Id ID_FILE_PRINT CommandBars.Actions(ID_FILE_PRINT).Caption = _ "Print Document" 'Change the ToolTipText of ALL items with Id ID_FILE_OPEN CommandBars.Actions(ID_FILE_OPEN).ToolTipText = _ "Open an existing document" End Sub
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: