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

MouseEnter for RightItems container elements

8 Answers 8 Views
TabbedForm
This is a migrated thread and some comments may be shown as answers.
Serg
Top achievements
Rank 1
Veteran
Serg asked on 23 Jan 2021, 10:07 AM
"RightItems" has several elements of type "RadButtonElement". How to listen for the "MouseEnter" event of the container that contains the "RadButtonElement".
For example, to change the color of "RadButtonElement" when hovering over the container?

8 Answers, 1 is accepted

Sort by
0
Serg
Top achievements
Rank 1
Veteran
answered on 23 Jan 2021, 10:23 AM
0
Stoyan
Telerik team
answered on 26 Jan 2021, 05:53 AM

Hi Serg,

The buttons in the tabbed form are part of a single container. We do not have multiple containers for each button as you have shown in the drawing that you sent us.

You can see that there is one pixel space between the button and the container:

And both buttons are in a single container.

As far as I understand you want the button to be active in the area between the button and the container's border. You can set the margin of the RadButtonElement to "-1" and see if it will help in your case. This will remove the spacing between the buttons and the container.

If you are experiencing a different issue, please feel free to contact us at any time. You can also attach your project, if there is any specific behavior that you wish to show us.

Regards,
Stoyan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Serg
Top achievements
Rank 1
Veteran
answered on 26 Jan 2021, 10:50 AM

Maybe then it is possible to add some containers to RightItems, which will already contain a button with a given Margin? Is there such a solution?

I would be grateful for a hint on how to implement this.

0
Stoyan
Telerik team
answered on 27 Jan 2021, 09:09 PM

Hi Serg,

The TabbedForm contains two RadQuickAccessToolBar - left and right. They contain inner container among other primitives and elements. The inner container itself is a complex structure that is holding the buttons. We cannot change how the TabbedForm is designed, because we will break the current behavior. 

If you can describe your use case in details, we can try to think of a suggestion for your problem. 

In any case, write back with more information and we will see what we can do.

Regards,
Stoyan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Serg
Top achievements
Rank 1
Veteran
answered on 27 Jan 2021, 09:33 PM
I want to understand if it is possible in RightItems to add a container element, and add a button inside it.
To get the following result shown in the picture.
0
Stoyan
Telerik team
answered on 28 Jan 2021, 04:15 PM

Hello Serg,

As far as I understood your problem, here is what I can suggest:

        public RadForm1()
        {
            InitializeComponent();

            // Create RadButtonElement
            Telerik.WinControls.UI.RadButtonElement radButtonElement = new Telerik.WinControls.UI.RadButtonElement();
            radButtonElement.Name = "radButtonElement";
            radButtonElement.StretchHorizontally = false;
            radButtonElement.StretchVertically = false;
            radButtonElement.Text = "Button";
            radButtonElement.Click += RadButtonElement_Click;
            radButtonElement.Margin = new Padding(2, 2, 0, 0);
            radButtonElement.MouseLeave += RadButtonElement_MouseLeave;

            // Create LightVisualElement, which will act as a container for the button
            Telerik.WinControls.UI.LightVisualElement lightVisualElement = new Telerik.WinControls.UI.LightVisualElement();
            lightVisualElement.MouseEnter += LightVisualElement_MouseEnter;
            lightVisualElement.MouseLeave += LightVisualElement_MouseLeave;
            lightVisualElement.ShouldHandleMouseInput = true;
            lightVisualElement.Children.Add(radButtonElement); // add the button to the container

            // Add the LightVisualElement to the RightItems' collection 
            // Note: you can add any RadItem in this collection
            this.radTabbedFormControl1.RightItems.AddRange(new Telerik.WinControls.RadItem[] {
            lightVisualElement});
        }

        private void LightVisualElement_MouseEnter(object sender, EventArgs e)
        {
            // When entering the LightVisualElement, set IsMouseOver to true.
            // This will simulate that the mouse pointer is over the button.
            Telerik.WinControls.UI.LightVisualElement lve = sender as Telerik.WinControls.UI.LightVisualElement;
            if (lve != null && lve.Children.Count >= 1)
            {
                Telerik.WinControls.UI.RadButtonElement buttonElement = lve.Children[0] as Telerik.WinControls.UI.RadButtonElement;
                if (buttonElement != null)
                {
                    buttonElement.IsMouseOver = true;
                }
            }
        }

        private void LightVisualElement_MouseLeave(object sender, EventArgs e)
        {
            // Do not forget to set the IsMouseOver to false, when leaving the control
            Telerik.WinControls.UI.LightVisualElement lve = sender as Telerik.WinControls.UI.LightVisualElement;
            if (lve != null && lve.Children.Count >= 1)
            {
                Telerik.WinControls.UI.RadButtonElement buttonElement = lve.Children[0] as Telerik.WinControls.UI.RadButtonElement;
                if (buttonElement != null)
                {
                    buttonElement.IsMouseOver = false;
                }
            }
        }

        private void RadButtonElement_MouseLeave(object sender, EventArgs e)
        {
            // We need to keep IsMouseOver to true, when leaving the button
            // and set it to false, when leaving the LightVisualElement
            Telerik.WinControls.UI.RadButtonElement buttonElement = sender as Telerik.WinControls.UI.RadButtonElement;
            if (buttonElement != null)
            {
                buttonElement.IsMouseOver = true;
            }
        }

I use LightVisualElement as a container for the RadButtonElement. You can use any container you like instead, I am using LightVisualElement for demonstration purposes.

I have also added code that is setting IsMouseOver through some event handlers - I think that is what you wanted to achieve. I suggest experimenting with this solution to fit it best to your particular needs. You can also adjust the Margins/Paddings of the LightVisualElement and RadButtonElement, so you can achieve your desired result.

If you have further questions, don't hesitate to contact me.

Regards,
Stoyan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Serg
Top achievements
Rank 1
Veteran
answered on 28 Jan 2021, 05:14 PM
Did I understand correctly that in this way you can add any controls to RightItems? For example a standard TableLayoutPanel control?
I thought only controls from Telerik can be added to RightItems.
0
Stoyan
Telerik team
answered on 29 Jan 2021, 10:07 AM

Hello Serg,

Only Telerik items can be used. You can use elements that inherit RadItemhttps://docs.telerik.com/devtools/winforms/telerik-presentation-framework/class-hierarchy/raditem. 

Regards,
Stoyan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
TabbedForm
Asked by
Serg
Top achievements
Rank 1
Veteran
Answers by
Serg
Top achievements
Rank 1
Veteran
Stoyan
Telerik team
Share this question
or