Caption/Label for BarComboBox

Bars for Windows Forms Forum

Posted 10 years ago by Justin Bozonier
Version: 2.0.0107
Avatar
I'm using the following code to add a combo box to my toolbar. I want to show the text of the combo box next to it. How do I do that?

var mainScalingBarComboBoxCommand = new BarComboBoxCommand("Main", "Scaling", "Scaling", -1);
mainScalingBarComboBoxCommand.Items.Add("None");
mainScalingBarComboBoxCommand.Items.Add("Thousands");
mainScalingBarComboBoxCommand.Items.Add("Millions");
mainScalingBarComboBoxCommand.Items.Add("Billions");
mainScalingBarComboBoxCommand.Tag = "Scaling";
mainScalingBarComboBoxCommand.Text = "Scaling";
var mainScalingBarComboBoxLink = new BarComboBoxLink(mainScalingBarComboBoxCommand);
mainScalingBarComboBoxLink.Image = Properties.Resources.goto_16;
mainScalingBarComboBoxLink.DisplayStyle = BarCommandLinkDisplayStyle.ImageAndText;
mainScalingBarComboBoxLink.DefaultText = "Scaling";
mainScalingBarComboBoxLink.Text = "Scaling";
My current "solution" is to create a disabled button next to it as a label. The problem is that this button's text is vertically off-center.

var labelButtonCommand = new BarButtonCommand("Main", "ScaleLabel", "Scale: ", -1);
var labelButtonLink = labelButtonCommand.CreateCommandLink();// new BarButtonLink(labelButtonCommand);
labelButtonLink.DisplayStyle = BarCommandLinkDisplayStyle.TextOnly;
labelButtonCommand.Tag = "Scale";
labelButtonCommand.Text = "Scale: ";
labelButtonCommand.Enabled = false;
Thanks in advance for your help!

Comments (1)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Maybe try using a BarLabelLink and related command instead. That is intended to be a static label and should look better than a disabled button would.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 5 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.