Outlook RibbonX, getting handle to a textbox on the ribbon

S

Scev

This seems like it should be easy to do, but I'm not sure how. I have a
custom RibbonX app written in C# .Net for Outlook, I've been able to add
buttons and handle the click events etc. BUT what I need to do is get a
handle to a control on the ribbon other than the control the raised the event.

Specifically when in the Callback for a button click event I want to get a
handle to a textbox control to get and update the content of that textbox
control in the ribbon. In the same thought, when a user clicks send to send
an email I need to gain a handle to that same textbox control to read the
text value that is in the control. I was looking for a getControl (ID) type
of a call but I’m not sure if that exists and if it does that object I would
call it from.

Any help would be GREAT! I’m not finding a lot of helpful resources on the
..Net regarding stuff like this.
 
K

Ken Slovak - [MVP - Outlook]

What sort of control is this, is it an editBox control?

Is this a user created control you are adding to the ribbon? You should know
the id for that control if you are adding it. You can set up to handle the
getText callback and force that to fire by calling either
Ribbon.InvalidateControl() with the id of that control, or you can call
Ribbon.Invalidate() to force callbacks to fire on all of your user added
ribbon controls.
 
S

Scev

No this is the built in editBox control. I do know the ID of the control.
In my ribbon XML I have this:

<button id="attachButton" onAction="Attach_Click" label="Attach To Case"
showImage="false" />
<editBox id="reditBox" label="Case No.:" showImage="false" visible="true" />

and in my code I have this:

public void Attach_Click(Office.IRibbonControl control)
{
Microsoft.Office.Interop.Outlook.Inspector ins = control.Context
as Microsoft.Office.Interop.Outlook.Inspector;
if (ins != null)
{
....
}
}

What I was looking for is some way to do SOMETHING like this:

object X = ribbon.GetControl("reditBox");

Where X is the editBox defined above. Then I could read the Text value from
the edit box in my code.

I appreciate your response, and it sounds like you know the answer to my
question, but I’m still not clear on how, or if this can be done. Based on
the structure that I’ve shows can you maybe give me more specific help? Or
am I totally off base.
 
K

Ken Slovak - [MVP - Outlook]

The Office 2007 object model has CommandBars.ExecuteMso and a whole series
of GetXXXMso methods where XXX is some property. ExecuteMso would click the
control. Unfortunately it looks like none of those does what you want.

A combination of tricks might work. If you use a <command> section in your
ribbon XML you can repurpose many of the built-in ribbon controls. Some of
the controls, like the big Send button, you can't repurpose, but most of
them can be used.

If you handle the callback for a click in the control you can do whatever
you want before passing the event to the default handler or cancelling the
event. You'd click the control to initiate the process.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top