The goal is to add the standard Solver button to a custom ribbon.
Background: I have code that creates a Solver model automatically using custom ribbon buttons. However, before actually running Solver, I would like the user to verify, and modify as necessary, the automatically-generated Solver model - by showing the Solver Parameters dialog box. For the user's convenience, I want to put the standard Solver button on my custom ribbon.
Problems were:
Solver does not have an official Microsoft msoImage or onAction item. So, I created my own button that called SolverOkDialog(). BUT,...
SolverOkDialog does not display the Solver Parameters dialog box (at least I couldn't get it to do so).
Solution:
Big picture: Grab the icon and link from Solver.xlam.
Copy C:\Program Files (x86)\Microsoft Office\Office15\Library\SOLVER\SOLVER.XLAM to a new file, Solver.zip.
Copy ….zip\customui\images\solver_icon.png to someplace convenient.
Using your favorite ribbon xml editor(1) assign solver_icon to RibbonX14.
Insert the following code to your custom ribbon:
<button id="btnSolver"
getLabel="solver.xlam!GetSolverLabel"
image="solver_icon"
onAction="solver.xlam!MainEx"
screentip="Solver"
supertip="What-if analysis tool that finds the optimal value of a target cell by changing values in cells used to calculate the target cell."/>
I hope this helps someone.
If I am missing something, please let me know.
(1) I use Leaf Creations Office Ribbon Editor because it is simple, functions well, and it is Creative Commons compliant.
Related
I have two toolbars desgined of equal size and equal number of buttons.
Now based on some condition in code I want to change toolbars run time.
My prject is MDI application built in Visual C++2010 MFC.
Please help as early as possible.My application uses CMFCToolbar
If you are using CMFCToolbar you can just call: CMFCToolbar::GetCommandButtons (a static function). You get an Object array of all buttons in your system and you can change them accordingly (SetToolTip, SetImage ...)
The problem is that CMFCToolbar is variable and buttons can be inserted and dragged around. SO you need the access via GetCommandButons.
If you are using the classical CToolBar class the easiest way is just to add the button, so it always exists in the toolbar and in the bitmap.
If the button should not be visible at startup you just call DeleteButton with the index you receive from CommandToIndex.
To change the button you can just use SetButtonInfo.
If you need the button again, just call InsertButton, with the index where you want to have this button.You may save the previous index and used bitmap index before you delete it.
In my Android project I've already created a custom dialog: A class named SelectColorDialog, extending Dialog, that allows the user to view a large matrix of color cells in order to select a particular color. The dialog returns the selected color value (as Integer) to the dialog initiator – typically an Activity – via a callback function.
I've a similar custom dialog, SelectTypefaceDialog, to allow easy font selection. A list of available typefaces are shown, as ListView rows, each identified by name and with an associated short sample text rendered in that typeface. The available typefaces include usual droid fonts, such as NORMAL, MONOSPACE, etc. as well as any externally sourced TTF font files that the user cares to load into a particular subdirectory on the SDCard.
These custom dialogs were not initially designed to be used directly in conjunction with SharedPreferences, preferences definition XML files or with any PreferenceActivity. Instead of, each dialog can be popped up from any activity, via the user pressing a button or via a menu item. The activity classes that create these dialogs also have internal callback classes, selection event listeners, to detect when the user selects a color or font.
These two dialogs do not have OK and Cancel buttons. Instead, the user just clicks on an item - a view of some kind - in the dialog to select the corresponding color or typeface value (implicit OK) or else presses the device’s back button to dismiss the dialog with no action taken (implicit Cancel).
I would now like to go further and incorporate these two custom dialogs into the shared preferences framework via a preferences.XML and an associated PreferenceActivity.
I would prefer to base two DialogPreference subclasses directly on these existing dialogs if possible, but I cannot see how to do so. I suspect that I cannot, and that I'll need to start all over again, and copy or adapt all the java code that is presently in the custom dialog classes – for color or font display and selection – directly into the custom DialogPreference classes instead, perhaps by overriding onCreateDialogView() and/or other methods?
This question may be a bit old, but I hope to help those, looking at the same problem in future: just extend Preference instead of DialogPreference. DialogPreference is designed badly and expected "official" way to use custom Dialog - overriding protected showDialog method does not work, because this single method contains half of class logic.
I'm trying to hide the 'Add Existing' button for a custom entity subgrid on the Contact form. My steps so far;
Add Contact entity to solution
Export solution and load up customisations.xml in VS2010
Add following to CustomAction node
<HideCustomAction HideActionId="sample.Mscrm.SubGrid.new_gppractice.AddExistingAssoc.HideAction" Location="Mscrm.SubGrid.new_gppractice.AddExistingAssoc" />
<HideCustomAction HideActionId="sample.Mscrm.SubGrid.new_gppractice.AddExistingStandard.HideAction" Location="Mscrm.SubGrid.new_gppractice.AddExistingStandard" />
Save, reimport
Upon trying to reimport I get the following error:
The ribbon item 'sample.Mscrm.SubGrid.new_gppractice.AddExistingAssoc.HideAction' is dependent on ribbon control id='Mscrm.SubGrid.new_gppractice.AddExistingAssoc'
The ribbon item 'sample.Mscrm.SubGrid.new_gppractice.AddExistingStandard.HideAction' is dependent on ribbon control id='Mscrm.SubGrid.new_gppractice.AddExistingStandard'
Any ideas why I'm getting these errors?
Can't say I have an actual explanation for why this has failed.
However I can suggest trying: Ribbon Workbench, it makes these sort of customizations significantly easier.
For programming Office Add-ins using C# 4.0, Microsoft provides two different ways of creating and/or modifying the Ribbon interface: you can use the Ribbon Designer or define the Ribbon's layout in Ribbon XML.
If you create a ribbon using the Ribbon designer, the class generated in the code behind has visibility to all the controls you've placed on the ribbon. So if I've placed a RibbonDropDown called "dropdown1", I could use the following code to add an item to it:
RibbonDropDownItem item = Factory.CreateRibbonDropDownItem();
item.Label = submatrix.Name;
item.Tag = submatrix;
this.dropDown1.Items.Add(item);
However, if you create the same Ribbon using Ribbon XML, dropDown1 or Factory aren't found ("The name does not exist in the current context").
Is there a way to access the items added to a Ribbon XML-defined ribbon in code?
Might be a little late, but hopefully this helps someone.
I was utterly confused about this same issue. Turns out, you can only access these controls as string ids, and the model is heavy on invalidation events. So for example, when you get a button click via onAction method, you only have the sender's id from the control object, however, in this event handler, you can invalidate the other controls and have their events called using
ribbon.InvalidateControl("MyCtl");
check out this MS Lab, it has everything you need to get up and running
I have already asked the same question but in regards with MDI Application design. Now just for R&D purpose so that we can go with 2 solutions to our user. Can somebody plz help me out...
We are developing an OutLook Style Application using C# Winforms. In that application we are using Microsoft Table Control. Which is what we need to show our UI. In the left hand pane we have menu and in the right hand we are displaying our UserControl. Like CustomerManager. This UserControl is doing Adding, Updating, Deleting ect etc but we want to put the common action buttons, Like Add,Delete,Save on the top toolbar.
So far so good, Now what we need to acheve is regardless of UserControl. What ever UserControl is loaded in the MainForm's TableControl. When the save button is clicked it should process the data on that UserControl. Obviously we will write the logic of the Save Action on each UserControl.
Please help...
Regards
Shanx
I may advice you the Krypton Toolkit. You will write an Outlook style app in seconds.
For all who ended up here like me in search of a free toolkit: As Vulkanino suggested to use Krypton, I loooked it up.
This is now open source Freeware and can be found unter: Krypton Toolkit
Create a Base user control that contains your Add, Delete, Save methods and events. Then create every other functional control that inherits from the Base control.
When you action the main toolbar buttons, you can safely cast each user control in your given container, to the Base user control.
Some MSDN links you might want to read up on:
http://msdn.microsoft.com/en-us/library/44a9ty12(VS.80).aspx
http://msdn.microsoft.com/en-us/library/ms173149(VS.80).aspx