|
Hi,
it worked fine for me, thank you.
|
|
|
|
|
Adding using designer is OK however there is a trouble adding using code, I think not only for RibbonComboBox but some others.
I tried creating new RibbonButton for each item of the DropDownItems and using Add() method of RibbonComboBox.DropDownItems, however the RibbonComboBox shows nothing. I guess I have to initialize some properties for the new RibbonButton but I see that there aren't many things to try, only the SetBounds() method but it's for nothing.
Please if doing this (a very basic task when programming with any kind of comboBox in C#) can be done, could you suggest me with some lines of code?
|
|
|
|
|
I cannot reproduce your behavior. For me the following works:
RibbonButton rb1 = new RibbonButton("ASDF");
rb1.Style = System.Windows.Forms.RibbonButtonStyle.DropDownListItem;
ribbonComboBox1.DropDownItems.Add(rb1);
|
|
|
|
|
And here is my code, just try loading a list of installed font on the current system to the RibbonComboBox:
public static void LoadFontList(RibbonComboBox combo)
{
FontFamily[] families = new InstalledFontCollection().Families;
for (int i = 0; i < families.Length; i++)
{
RibbonButton button = new RibbonButton(families[i].Name);
combo.DropDownItems.Add(button);
}
}
The difference from your code is the optional line you commented, that is optional so I've not included it in, I'll try then. Thanks. (still not work)
|
|
|
|
|
Yes, the code should work well, and it does work when the count of items is small enough so that the total height of all menu items (also the height of the menu itself) is maximum at the height of the screen. And I think this is designed by you, I understand that RibbonComboBox doesn't have a scrollbar when it has too many items. It's a little different from the standard comboBox.
There are about more than 500 fonts installed on my computer, it's too many, I tried limiting the count added to the RibbonComboBox.DropDownItems to 24 (enough to fit the screen height) and it works, increase the count 1 or more will make it not work. However this is not what I want, I want to load all the installed fonts.
Now I think of RibbonHost and .NET ComboBox as a solution for this. Thanks for your reply
|
|
|
|
|
I think you are on the right way. Because the DropDown of a RibbonComboBox hosts a ToolStripDropDown. It does not inherit the ComboBox.
|
|
|
|
|
I miss a feature to change the font to bold (font-weight) of the RibbonLabel...
and a gray backcolor (or any other color) for dropdownitems
|
|
|
|
|
Font is Ribbon.Font.
Be more specific on the dropdownitems - I don't get you.
|
|
|
|
|
RibbonLabel lbl = new RibbonLabel();
lbl.Text = "Bold Text, but how? And Background in gray like in office";
RibbonButton rbtn = new RibbonButton();
rbtn.Text = "Hello World";
rbtn.CheckOnClick = true;
ribbon.QuickAcessToolbar.DropDownButton.DropDownItems.Add(lbl);
ribbon.QuickAcessToolbar.DropDownButton.DropDownItems.Add(rbtn);
ribbon.QuickAcessToolbar.DropDownButton.Style = RibbonButtonStyle.DropDown;
ribbon.QuickAcessToolbar.DropDownButton.DrawIconsBar = false;
|
|
|
|
|
The Font is fixed. It is the font of the Ribbon.
You can change the dropdown menu backcolor only on a global Level.
public Color DropDownBg = FromHexStr("#FAFAFA");
public Color DropDownImageBg = FromHexStr("#E9EEEE");
public Color DropDownImageSeparator = FromHexStr("#C5C5C5");
public Color DropDownBorder = FromHexStr("#868686");
public Color DropDownGripNorth = FromHexStr("#FFFFFF");
public Color DropDownGripSouth = FromHexStr("#DFE9EF");
public Color DropDownGripBorder = FromHexStr("#DDE7EE");
public Color DropDownGripDark = FromHexStr("#5574A7");
public Color DropDownGripLight = FromHexStr("#FFFFFF");
|
|
|
|
|
but that would change the font from all labels, right?
but i want bold texts and normal texts
|
|
|
|
|
Yes, that would change the font of everything.
If you want to have specific fonts, you have to do it on your own. Hint: if you do so, ensure to adapt all MeasureSize functions otherwise the layout might look strange.
|
|
|
|
|
This bug is really strange, why? because it happens to RibbonButton (I'm not sure if this is the only case).
But there are many RibbonButtons on my Ribbon and most of them are tooltipped OK, however there are 2 buttons with something special (I'm not sure) and they helped me discover this annoying bug.
I have 2 pairs of 2 RibbonButtons, 2 buttons called Color 1 and Color 2 on Home tab and other 2 buttons also called Color 1 and Color 2 on Text tab. To help differentiate between those pairs of buttons, I will call the Color 1 and Color 2 buttons on Text tab Text color 1 and Text color 2 buttons respectively.
Here is the description for the bug:
When I move the mouse over the Color 1, the tooltip should appear/be shown near under the mouse position (and this leads to a result that the tooltip is beneath the Color 1), however it appears as if it was the tooltip for Text color 1, but the tooltip's text is really the text I specified for Color 1 not for Text Color 1. In other words, the tooltip is misplaced, instead of being placed near under Color 1 it is placed near under Text color 1 (although the Text color 1 on Text tab can't be seen at the moment).
All other RibbonButtons on my form are OK, and the special thing I mentioned before is there are 2 pairs of buttons which really have the same appearance and function in this case. (The only difference is they are placed on different tabs).
Here are 2 snapshots I took to help you associate the problem better:
Pic 1
Pic 2
Thank you!
|
|
|
|
|
Strange indeed.
Which version of the ribbon are you using? Because on my machine the location of the tooltip is always relative to the current mouse position.
|
|
|
|
|
I'm sorry to say that at first I used ver 3.5.5.0 but then I tried changing to ver 3.5.6.1 and the bug still exists. As I said, all other RibbonButtons on my form seems to work OK, except those Color 1 and Color 2 buttons. (The Color 1 and Color 2 buttons on Text tab work well however the Color 1 and Color 2 buttons on Home tab don't).
You should focus on the special thing I pointed out, I can't understand why those pairs of Color buttons can involve each other and make any difference from other buttons.
At first, I tried moving the Color 1 and Color 2 buttons from Home tab to Text tab when Text tab is selected, however it seems that you're in your way developing this ribbon control, such a moving seems to be not easy. (Moving is OK but the Position after being moved is not changed and seems to be unable to change, I found only SetBounds() method but even it couldn't help). That's why I have to create separated pairs of Color 1 and Color 2 buttons, each pair for each tab (Home and Text tabs).
Hope you can fix this bug soon! I think this bug is not really serious because it hardly appears, just in a special case as of mine. Thanks!
|
|
|
|
|
You are not by any chance using twice the same button (meaning the same instance)?
Can you post somewhere the piece of code which builds up the ribbon. As mentioned before the ToolTip stays relative to the mouse cursor in my application.
|
|
|
|
|
I'm sure to say that those pairs of Color 1 and Color 2 buttons on Home tab and Text tab are different (not the same instances), here is some of the code automatically generated for all Color 1/2 buttons on both tabs:
this.ribBtnColor1.AltKey = null;
this.ribBtnColor1.Checked = true;
this.ribBtnColor1.CheckedGroup = null;
this.ribBtnColor1.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
this.ribBtnColor1.DropDownArrowSize = new System.Drawing.Size(5, 3);
this.ribBtnColor1.Image = ((System.Drawing.Image)(resources.GetObject("ribBtnColor1.Image")));
this.ribBtnColor1.ShowFlashImage = false;
this.ribBtnColor1.SmallImage = ((System.Drawing.Image)(resources.GetObject("ribBtnColor1.SmallImage")));
this.ribBtnColor1.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
this.ribBtnColor1.Tag = null;
this.ribBtnColor1.Text = "Color 1";
this.ribBtnColor1.ToolTip = "Click here and then select a color from the color palette. This color is used wit" +
"h the pencil and with brushes, as well as for shape outlines.";
this.ribBtnColor1.ToolTipTitle = "Color 1";
this.ribBtnColor1.Value = null;
this.ribBtnColor1.Click += new System.EventHandler(this.ColorButtonsClicked);
this.ribBtnColor2.AltKey = null;
this.ribBtnColor2.CheckedGroup = null;
this.ribBtnColor2.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
this.ribBtnColor2.DropDownArrowSize = new System.Drawing.Size(5, 3);
this.ribBtnColor2.Image = ((System.Drawing.Image)(resources.GetObject("ribBtnColor2.Image")));
this.ribBtnColor2.ShowFlashImage = false;
this.ribBtnColor2.SmallImage = ((System.Drawing.Image)(resources.GetObject("ribBtnColor2.SmallImage")));
this.ribBtnColor2.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
this.ribBtnColor2.Tag = null;
this.ribBtnColor2.Text = "Color 2";
this.ribBtnColor2.ToolTip = "Click here and then select a color from the color palette. This color is used wit" +
"h the eraser and for shape fills.";
this.ribBtnColor2.ToolTipTitle = "Color 2 (background color)";
this.ribBtnColor2.Value = null;
this.ribBtnColor2.Click += new System.EventHandler(this.ColorButtonsClicked);
this.ribbonBtnTextColor1.AltKey = null;
this.ribbonBtnTextColor1.Checked = true;
this.ribbonBtnTextColor1.CheckedGroup = null;
this.ribbonBtnTextColor1.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
this.ribbonBtnTextColor1.DropDownArrowSize = new System.Drawing.Size(5, 3);
this.ribbonBtnTextColor1.Image = ((System.Drawing.Image)(resources.GetObject("ribbonBtnTextColor1.Image")));
this.ribbonBtnTextColor1.ShowFlashImage = false;
this.ribbonBtnTextColor1.SmallImage = ((System.Drawing.Image)(resources.GetObject("ribbonBtnTextColor1.SmallImage")));
this.ribbonBtnTextColor1.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
this.ribbonBtnTextColor1.Tag = null;
this.ribbonBtnTextColor1.Text = "Color 1";
this.ribbonBtnTextColor1.ToolTip = "Click here and then select a color from the color palette. This color is used wit" +
"h the pencil and with brushes, as well as for shape outlines.";
this.ribbonBtnTextColor1.ToolTipTitle = "Color 1 (foreground color)";
this.ribbonBtnTextColor1.Value = null;
this.ribbonBtnTextColor1.Click += new System.EventHandler(this.ColorButtonsClicked);
this.ribbonBtnTextColor2.AltKey = null;
this.ribbonBtnTextColor2.CheckedGroup = null;
this.ribbonBtnTextColor2.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
this.ribbonBtnTextColor2.DropDownArrowSize = new System.Drawing.Size(5, 3);
this.ribbonBtnTextColor2.Image = ((System.Drawing.Image)(resources.GetObject("ribbonBtnTextColor2.Image")));
this.ribbonBtnTextColor2.ShowFlashImage = false;
this.ribbonBtnTextColor2.SmallImage = ((System.Drawing.Image)(resources.GetObject("ribbonBtnTextColor2.SmallImage")));
this.ribbonBtnTextColor2.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
this.ribbonBtnTextColor2.Tag = null;
this.ribbonBtnTextColor2.Text = "Color 2";
this.ribbonBtnTextColor2.ToolTip = "Click here and then select a color from the color palette. This color is used wit" +
"h the eraser and for shape fills.";
this.ribbonBtnTextColor2.ToolTipTitle = "Color 2 (background color)";
this.ribbonBtnTextColor2.Value = null;
this.ribbonBtnTextColor2.Click += new System.EventHandler(this.ColorButtonsClicked);
I'm going to post a link here for you to download the current project of mine, you can run it at least with VS 2008 to see the bug in action: MSPaint form
Thanks!
|
|
|
|
|
OK, I can see that the ToolTip is !sometimes! off. It seems to me that it is related to the fact that the button changes its position depending on the size of the ribbon.
|
|
|
|
|
You can find more some bugs related to tooltip just by playing around with the project I uploaded, for example, RibbonButton with checked state (last checked button) can have its tooltip shown at the same time with the tooltip of another RibbonButton which is currently under the mouse pointer (2 tooltips overlap each other that looks really ugly).
|
|
|
|
|
That should be fixed easily.
Create a static ToolTip member (RibbonItem.cs):
private static RibbonToolTip lastActiveToolTip;
In the OnMouseMove change the following (single) line:
public virtual void OnMouseMove(MouseEventArgs e)
{
...
_TT.Active = true;
...
}
to that (3 lines):
public virtual void OnMouseMove(MouseEventArgs e)
{
...
if (lastActiveToolTip != null) lastActiveToolTip.Active = false;
_TT.Active = true;
lastActiveToolTip = _TT;
...
}
Remark: not tested, not event entered in VS - just a hint
modified 4-Mar-13 8:57am.
|
|
|
|
|
Do you mean the OnMouseMove of RibbonButton? I'm not sure about other RibbonItems if this bug can happen to them, not only RibbonButton. Thanks!
|
|
|
|
|
No. I was referring to the RibbonItem (sorry, that I did not mention this, but you can search for the line posted above). Then you have it in all RibbonItems - except the RibbonTab.
|
|
|
|
|
if i want to add a optionsitem with the designer (with click on the purple plus Button)
my visual studio crashs
|
|
|
|
|
You mean in the OrbDropDown menu? On my VS2010 that works. Start a second instance of VS and attach to the other VS process.
|
|
|
|
|
i will try this, if it happens again!
thanks for this tip, that was new for me
|
|
|
|