Popup command bars |
Post Reply |
Author | |
AndyLUK
Newbie Joined: 14 February 2022 Location: UK Status: Offline Points: 3 |
Post Options
Thanks(0)
Posted: 17 February 2022 at 3:45pm |
Hi.
I am new to codejock and have been struggling to get Popup Command Bars to work in C#. It compiles OK but when I run the code I get a "Catastrophic COM failure ..." I've clearly not understood the nuances of calling a Popup. Can anyone help? Cheers Andy My code is as follows. private void LaunchPopup() { CommandBars cmdbars; CommandBar popupbar; CommandBarControl control; cmdbars = new CommandBars(); //This doesn't work and the subsequent line throws the error popupbar = cmdbars.Add("Popup", XTPBarPosition.xtpBarPopup); popupbar.Controls.Add(XTPControlType.xtpControlButton, 1, "&New", -1, false); popupbar.Controls.Add(XTPControlType.xtpControlButton, 2, "&Open", -1, false); popupbar.Controls.Add(XTPControlType.xtpControlButton, 3, "&Save", -1, false); control = popupbar.Controls.Add(XTPControlType.xtpControlButton, 4, "&Print", -1, false); control.BeginGroup = true; popupbar.ShowPopup(); } |
|
AndyLUK
Newbie Joined: 14 February 2022 Location: UK Status: Offline Points: 3 |
Post Options
Thanks(0)
|
Hi.
I was trying to get a popup menu to appear when clicking on a ReportControl column header. After much experimenting and reverse engineering of the Codejock Samples I eventually got it to work. It would be great if there was an introduction document to the use of these controls or a You tube video showing the basics for newbies but hey ho. Anyway the code below is what I ended up with. I have documented the best I can and maybe it will be of some use to another newbie. cheers Andy private void wndReportControl_ColumnClick(object sender, AxXtremeReportControl._DReportControlEvents_ColumnClickEvent e) { //this is if you right click on a column head - see SendContextMenuForWholeHeaderArea property if you want //all columns to have the same ColumnClick event //MessageBox.Show("col click"); LaunchPopup(); } private void LaunchPopup() { //the following "using" statements are required //using XtremeReportControl; //using XtremeCommandBars; CommandBar popupbar; CommandBarPopup popup2; CommandBarControl control, pu_andy1, pu_andy2; //N.B. you can't "new up" a command bar you need a command bar object on your form otherwise you //get a "Catastrophic COM failure ..." error when you run it. //create the base command bar and add some buttons - the ID class defines a unique number for each button //see Codejock samples popupbar = axCommandBars1.Add("andy", XTPBarPosition.xtpBarPopup); popupbar.Controls.Add(XTPControlType.xtpControlButton, ID.FILE_NEW_FILE, "&New", -1, false); popupbar.Controls.Add(XTPControlType.xtpControlButton, ID.FILE_OPEN_FILE, "&Open", -1, false); popupbar.Controls.Add(XTPControlType.xtpControlButton, ID.FILE_SAVE, "&Save", -1, false); //need to define popup2 as a command bar and cast the control so we can add more controls to it. popup2 = (CommandBarPopup)popupbar.Controls.Add(XTPControlType.xtpControlPopup, 9, "sub menu"); //add controls to the sub menu pu_andy1 = popup2.CommandBar.Controls.Add(XTPControlType.xtpControlButton, 901, "andy1", -1, false); pu_andy2 = popup2.CommandBar.Controls.Add(XTPControlType.xtpControlButton, 902, "andy2", -1, false); //add divider and last control to main menu control = popupbar.Controls.Add(XTPControlType.xtpControlButton, ID.FILE_PRINT, "&Print", -1, false); control.BeginGroup = true; //now setup the icons to use in the commandbar //you need an image control on the form popupbar.CommandBars.Icons = axImageManager1.Icons; //using default name of axImageManager1 //build an array to hold ID values int[] CommandBarIconArray = new int[20]; //load array (ID values are defined in another class and are used to identify each control uniquely) CommandBarIconArray[0] = ID.FILE_NEW_FILE; CommandBarIconArray[2] = ID.FILE_OPEN_FILE; CommandBarIconArray[3] = ID.FILE_SAVE; CommandBarIconArray[4] = ID.FILE_SAVE_ALL; CommandBarIconArray[5] = ID.FILE_PRINT; //load the icons from the Toolbar.png file - see icons folder in codejock samples popupbar.CommandBars.Icons.LoadBitmap(ID.IconsPath() + "Toolbar.png", CommandBarIconArray, XtremeCommandBars.XTPImageState.xtpImageNormal); //display the popup - by default this is in the middle of the screen but there are coordinate parameters to "ShowPopup() popupbar.ShowPopup(); } |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |