SoftCreator

Hello.

I created group with 3 toggle buttons:

<group id="SData" label="S Data">
<toggleButton id="SDataAssignmnets"
size="large"
label="Assignments"
screentip="Show/hide external data Task Pane"
onAction="OnSDataButton"
image="Folders 32 n p.png" />

<toggleButton id="SDataCustomers"
size="large"
label="Customers"
screentip="Show/hide external data Task Pane"
onAction="OnSDataButton"
image="File and Folder 2 32 n p.png" />

<toggleButton id="SDataContacts"
size="large"
label="Contacts"
screentip="Show/hide external data Task Pane"
onAction="OnSDataButton"
image="Contact 32 h p.png" />
</group>

I want to use they like radiobuttons (only one button can be pressed simultaneously). How can I do that


Re: Visual Studio Tools for Office Ribbon menu and Toggle buttons

Dennis Wallentin

Hi,

This forum explicit target VSTO technology. For specific RibbonX questions the best place would be at pschmid's forum. Stephen Bullen has recently published the chapter about RibbonX from Bullen et al book "Excel 2007 VBA Programmer's reference" which may be useful. It's my understanding that radiobuttons are not available in RibbonX and the Togglebutton does not work in that way.






Re: Visual Studio Tools for Office Ribbon menu and Toggle buttons

FS2K

Hi !!

Possible work around

<group id="SData" label="S Data">
<toggleButton id="SDataAssignmnets"
size="large"
label="Assignments"
screentip="Show/hide external data Task Pane"
onAction="OnSDataButton"
image="Folders 32 n p.png"
getPressed="GetPressed"/>

<toggleButton id="SDataCustomers"
size="large"
label="Customers"
screentip="Show/hide external data Task Pane"
onAction="OnSDataButton"
image="File and Folder 2 32 n p.png" />
getPressed="GetPressed"/>

<toggleButton id="SDataContacts"
size="large"
label="Contacts"
screentip="Show/hide external data Task Pane"
onAction="OnSDataButton"
image="Contact 32 h p.png"
getPressed="GetPressed"/>


group>

private bool _SDataAssignmnetsPressed = false;
private bool _SDataCustomersPressed = false;
private bool _SDataContactsPressed = false;

public bool GetPressed(Office.IRibbonControl control)

{

switch (control.Id)

{

case "SDataAssignmnets":
if (_SDataAssignmnetsPressed) return true;
return false;
case "SDataCustomers":

...

case "SDataContacts":

...

}

}


public void OnSDataButton(Office.IRibbonControl control, bool IsPressed)

{
switch (control.Id)
{
case "SDataAssignmnets":
_SDataAssignmnets = true;
_SDataCustomersPressed = false;
_SDataContactsPressed = false;
...
case "SDataCustomers":
...
case "SDataContacts":
...
}

this.ribbon.Invalidate();
}

best regards

Franck





Re: Visual Studio Tools for Office Ribbon menu and Toggle buttons

SoftCreator

Thank's for links Denis. Very useful forum!



Re: Visual Studio Tools for Office Ribbon menu and Toggle buttons

SoftCreator

Thank you very much, Franck!

It works!

small offtopic:

why you written

if (_SDataAssignmnetsPressed) return true;
return false;

Is it some of best practice codestyle I think this looks bit better:

return _SDataAssignmnetsPressed;