This is a migrated thread and some comments may be shown as answers.

highlight button

2 Answers 128 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
petr
Top achievements
Rank 1
petr asked on 25 Feb 2010, 05:33 PM

Buttons added to the Ribbon bar in design time and dynamically seems to have the different behavior on mouse hoover. Meanwhile when I move mouse over buttons added in design time they are highlighted, dynamically added button are not highlighted. How can I set up this behavior thru program code?

Here is my method for adding buttons to the button group:

private void AddItemToButtonGroup(RadRibbonBarGroup group, String ItemName, String ItemText, String ItemDescription)

                        {

                                   RadButtonElement item = new RadButtonElement();

                                   item.DisplayStyle = DisplayStyle.ImageAndText;

                                   item.TextImageRelation = TextImageRelation.ImageBeforeText;

                                   item.ImageAlignment = ContentAlignment.MiddleCenter;

                                   item.Name = ItemName;

                                   item.Text = ItemText;

                                   item.ShowBorder = true;

                                   item.TextWrap = true;

                                   item.Margin = new Padding(1);

                                   item.TextAlignment = ContentAlignment.MiddleCenter;

                                   item.ToolTipText = ItemDescription;

                                   item.MaxSize = new Size(80, 80);

                                   item.Click += new EventHandler(Item_Click);

                                   group.Items.Add(item);

                        }

2 Answers, 1 is accepted

Sort by
0
Accepted
Deyan
Telerik team
answered on 03 Mar 2010, 07:38 AM
Hello,

Thanks for contacting us and for the code snippet.

We were able to reproduce the issue that you describe. Please, refer to the following code snippet that I am providing as a workaround for this case:

RadButtonElement item = new RadButtonElement();
item.DisplayStyle = DisplayStyle.ImageAndText;
item.TextImageRelation = TextImageRelation.ImageBeforeText;
item.ImageAlignment = ContentAlignment.MiddleCenter;
item.Name = "ddewdwed";
item.Text = "dwedwedwed";
item.ShowBorder = true;
item.TextWrap = true;
item.Margin = new Padding(1);
item.TextAlignment = ContentAlignment.MiddleCenter;
item.ToolTipText = "dwdwdwedwedwedwe";
item.MaxSize = new Size(80, 80);
this.radRibbonBarGroup1.Items.Add(item);
item.ForceReApplyStyle();

As you can see, I have added the ForceReApplyStyle method code at the end to instruct the theming mechanism to refresh the styles of the button you have just added.

I would also like to inform you that this issue is addressed in the new release and you will not need to call ForceReApplyStyle in this case.

I hope this is helpful. You can write back anytime you need further help.

Regards,
Deyan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
petr
Top achievements
Rank 1
answered on 03 Mar 2010, 09:17 AM
Thank you for your answer. Proposed workaround works fine for me.
Tags
RibbonBar
Asked by
petr
Top achievements
Rank 1
Answers by
Deyan
Telerik team
petr
Top achievements
Rank 1
Share this question
or