This project has moved and is read-only. For the latest updates, please go here.
   customize classic UI in Access
   taken from Example05.cs
private void Example05Main()
   Office.CommandBarButton commandBarBtn;

   // start access
   _accessApplication = new Access.Application();

   // create database name 
   string fileExtension = GetDefaultExtension(_accessApplication);
   string documentFile = string.Format("{0}\\Example05{1}", 
fileExtension); // delete old database if exists if (System.IO.File.Exists(documentFile)) System.IO.File.Delete(documentFile); // create database DAO.Database newDatabase = _accessApplication.DBEngine.Workspaces[0].CreateDatabase(
documentFile, LanguageConstants.dbLangGeneral); // add a commandbar popup Office.CommandBarPopup commandBarPopup = (Office.CommandBarPopup)
_accessApplication.CommandBars["Menu Bar"].Controls.Add(MsoControlType.msoControlPopup); commandBarPopup.Caption = "commandBarPopup"; #region few words, how to access the picture /* you can see we use an own icon via .PasteFace() is not possible from outside process boundaries to use the PictureProperty directly the reason for is IPictureDisp: its not important is early or late binding or managed or unmanaged,
the behaviour is always the same For example, a COMAddin running as InProcServer and can access the Picture Property */
#endregion #region CommandBarButton // add a button to the popup commandBarBtn = (Office.CommandBarButton)commandBarPopup.Controls.Add(
MsoControlType.msoControlButton); commandBarBtn.Style = MsoButtonStyle.msoButtonIconAndCaption; commandBarBtn.Caption = "commandBarButton"; Clipboard.SetDataObject(this.Icon.ToBitmap()); commandBarBtn.PasteFace(); commandBarBtn.ClickEvent +=
new Office.CommandBarButton_ClickEventHandler(commandBarBtn_Click); #endregion // make visible _accessApplication.Visible = true; } void commandBarBtn_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault) { textBoxEvents.BeginInvoke(_updateDelegate, new object[] { "Click called." }); Ctrl.Dispose(); } private void UpdateTextbox(string Message) { textBoxEvents.AppendText(Message + "\r\n"); }

Last edited Jun 13, 2012 at 2:46 PM by SebastianDotNet, version 5


No comments yet.