highlight button

3 posts, 1 answers
  1. petr
    petr avatar
    3 posts
    Member since:
    Mar 2009

    Posted 25 Feb 2010 Link to this post

    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. Answer
    Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 03 Mar 2010 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. petr
    petr avatar
    3 posts
    Member since:
    Mar 2009

    Posted 03 Mar 2010 Link to this post

    Thank you for your answer. Proposed workaround works fine for me.
Back to Top