Adding a simple label to my CommandBar

F

Frenchy

Hi all,

I developed an add-in working with a CommandBar I created, I added, Combo
box and buttons but I can't add a simple label...

Here's how I add a button:

Btn = (CommandBarButton) oStandardBar.Controls.Add(1, missing , missing ,
missing , missing);

Does anyone knows how to add a simple label to a CommandBar ?

Thanks,

Frenchy
 
F

Frenchy

Sorry I forgot to mention that I’m working with visual C# .NET (extensibility
project)
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?RnJlbmNoeQ==?=,
I developed an add-in working with a CommandBar I created, I added, Combo
box and buttons but I can't add a simple label...

Here's how I add a button:

Btn = (CommandBarButton) oStandardBar.Controls.Add(1, missing , missing ,
missing , missing);

Does anyone knows how to add a simple label to a CommandBar ?
It's the Caption property, and you need to set the Style to msoComboLabel
(msoComboStyle enum)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
F

Frenchy

Hello,

The msoComboLabel style is for ComboBoxes(CommandBarComboBox).

I added a combobox with the msoComboLabel style, I have my beautiful
label...but then I have a combobox(empty). Here's my code:

private CommandBarComboBox Lbl = null;
object objType = MsoControlType.msoControlDropdown;
Lbl = (CommandBarComboBox)oStandardBar.Controls.Add(objType, missing,
missing, missing, (object)true);
Lbl.Caption = "test";
Lbl.Style = MsoComboStyle.msoComboLabel;


I tried to add directly labels but It fails.... I don't understand why the
easiest is the hardest


Thanks for your reply,

Frenchy
 
F

Frenchy

Hello,

The msoComboLabel style is for ComboBoxes(CommandBarComboBox).

I added a combobox with the msoComboLabel style, I have my beautiful
label...but then I have a combobox(empty). Here's my code:

private CommandBarComboBox Lbl = null;
object objType = MsoControlType.msoControlDropdown;
Lbl = (CommandBarComboBox)oStandardBar.Controls.Add(objType, missing,
missing, missing, (object)true);
Lbl.Caption = "test";
Lbl.Style = MsoComboStyle.msoComboLabel;


I tried to add directly labels but It fails.... I don't understand why the
easiest is the hardest


Thanks for your reply,

Frenchy
 
F

Frenchy

Hello,

The msoComboLabel style is for ComboBoxes(CommandBarComboBox).

I added a combobox with the msoComboLabel style, I have my beautiful
label...but then I have a combobox(empty). Here's my code:

private CommandBarComboBox Lbl = null;
object objType = MsoControlType.msoControlDropdown;
Lbl = (CommandBarComboBox)oStandardBar.Controls.Add(objType, missing,
missing, missing, (object)true);
Lbl.Caption = "test";
Lbl.Style = MsoComboStyle.msoComboLabel;


I tried to add directly labels but It fails.... I don't understand why the
easiest is the hardest


Thanks for your reply,

Frenchy
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?RnJlbmNoeQ==?=,

Perhaps I'm misunderstanding the question/problem. (Language barrier?) Do you
mean you don't find how to add entries to the dropdown list? Look for the
.AddItem method in the Office Help files.
I added a combobox with the msoComboLabel style, I have my beautiful
label...but then I have a combobox(empty). Here's my code:

private CommandBarComboBox Lbl = null;
object objType = MsoControlType.msoControlDropdown;
Lbl = (CommandBarComboBox)oStandardBar.Controls.Add(objType, missing,
missing, missing, (object)true);
Lbl.Caption = "test";
Lbl.Style = MsoComboStyle.msoComboLabel;


I tried to add directly labels but It fails.... I don't understand why the
easiest is the hardest


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
F

Frenchy

Hum...yes my english isn't perfect :/

So...I'd like to add a label (text) to the commandbar I created using C#
..NET extensibility project for Word(I suppose that's how it's called in
english)

I succeed adding these:

Microsoft.Office.Core.CommandBarButton
Microsoft.Office.Core.CommandBarPopup
Microsoft.Office.Core.CommandBarComboBox

to my CommandBar.

But I'm still searching to add a simple label.

I tried a lot of things like this:

??? = (???)oStandardBar.Controls.Add(MsoControlType.msoControlLabel, missing
, missing , missing , missing);

But I don't know what to put in here ???


Thanks Cindy for your replies,

Frenchy
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?RnJlbmNoeQ==?=,
I'd like to add a label (text) to the commandbar I created using C#
Note: most of my experience with using CommandBars is in the VBA
interface, where we're limited to the three basic types (button,
combobox, textinput). I know there are other kinds, and have even
played around with them a bit in the .NET environment, but I don't
have the list of all possible controls memorized.

That said, I have to wonder if a "label" type even exists, since it
wouldn't perform any action? Therefore, my suggestion would be to
create a BUTTON type and set its .Enabled property to FALSE so that
it can't be clicked. Should look and behave exactly like a label, I
would think?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
F

Frenchy

You're right, the button behave like a label...BUT the problem now is that
the label(button) is in gray...And didn't find anything to change the style
of disabled button (enable=false).

Well, I’ve asked this question in the msdn newsgroup france and here, and in
2 other forums. But no-one (except you) has been able to help me. Thanks you
for your help, but I think that you won’t solve my problem…Do you know
someone who could help-me? Or an other place where I could ask my question…?

Frenchy
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?RnJlbmNoeQ==?=,
You're right, the button behave like a label...BUT the problem now is that
the label(button) is in gray...And didn't find anything to change the style
of disabled button (enable=false).
Well, there'd always be the option of leaving the button enabled, but have the
code behind it "empty", so that nothing happens...

I had an opportunity today to open up the documentation on ControlButtons and I
do see two label types listed: msoControlLabel and msoControlLabelEx (enum values
15 and 24, resp.). We can't actively use these in VBA, only identify if a
particular control is that type. Did you try either of these?
Well, I’ve asked this question in the msdn newsgroup france and here, and in
2 other forums. But no-one (except you) has been able to help me. Thanks you
for your help, but I think that you won’t solve my problem…Do you know
someone who could help-me? Or an other place where I could ask my question…?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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