Hi,
I want to make a toolbar button selected by default when my form loads. I tried like this
this.utm.Ribbon.Tabs[0].Groups[1].Tools["Button7"].IsActiveTool = true;
in form_load but get an error
"Can't activate a tool that is not visible". This tool is visible, I am not sure why it's showing such an error.
Any help on this would be greatly appreciated.
Many Thanks
Ponnu
It sounds like the UIElement for the tool hasn't been created yet, which probably means the toolbars manager hasn't painted for the first time yet. Try placing your code in an event handler for the Shown event of the Form instead of the Load event.
Hi Mike,
Thanks, the selection worked in form shown event.
I have a problem with it though, the selection goes OFF as soon as I mouse over on a different tool button in the same or different group. I want the selection to be persistant(so the selction is always there until I select a different button in the SAME group). I am looking at something like the one in Outlook Appointment Item where the Appointment Toolbar button is selected always selected.
Thanks & Regards
In that case, you don't want to use IsActiveTool. This just deals with the focused or hot tracked tool. Instead, you should be using a StateButtonTool. Set the Checked property to True. If you want a few StateButtonTools to act as radio buttons in a group (where only one tool can be checked at any one time), add an OptionSet to the OptionSets collection of the toolbars manager and set it on the OptionSet property of each StateButtonTool in the group.
Why this code does not work? Does not matter what I do the ((StateButtonTool)TOOLBARS.Tools["Status Bar"]).Checked is always true, even when I check the values at run time, fl is FALSE when the ((StateButtonTool)TOOLBARS.Tools["Status Bar"]).InitializeChecked(fl); line is process.
private void TOOLBARS_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
case "Status Bar":
bool fl = ((StateButtonTool)TOOLBARS.Tools["Status Bar"]).Checked;
fl = !fl;
((StateButtonTool)TOOLBARS.Tools["Status Bar"]).InitializeChecked(fl);
break;
In order to set the check programmatically without invoking the ToolClick event, use the InitializeChecked method.
thank you, that is a solution i had thought.
You can set a flag in you application to ignore the ToolClick event before setting Checked programmatically. Reset the flag after setting the Checked property. In your ToolClick event handler, if the flag is True, just return.
ultraToolbarsManager1_ToolClick go off and i only want it to happen when really i will click the button state in the form.
There is a solution?
thanks