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.
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();
}