Declined
Last Updated: 01 Mar 2024 13:13 by ADMIN
Freddy
Created on: 13 Feb 2024 19:25
Category: UI for WinForms
Type: Bug Report
0
PerformClick method of RadButtonElement is sending System.InvalidCastException message error

PerformClick method of RadButtonElement is sending next error:

System.InvalidCastException: 'Unable to cast object of type 'System.EventArgs' to type 'System.Windows.Forms.MouseEventArgs'.

Find my code below:

private void btnAddField_Click(object sender, EventArgs e)
{
    RadDiagramShape sourceShape = new RadDiagramShape()
    {
        Text = "source",
        Shape = new RoundRectShape(5),
        BackColor = Color.Red
    };

    sourceShape.Position = new Telerik.Windows.Diagrams.Core.Point(150, 100);
    radDiagram.AddShape(sourceShape);

    sourceShape.IsSelected = true;
    RadButtonElement additionalContent = Telerik.WinControls.UI.Diagrams.Primitives.ItemInformationAdorner.GetAdditionalContent(
                                            this.radDiagram.DiagramElement.ItemInformationAdorner) as RadButtonElement;

    additionalContent.PerformClick();
}

What I want is to display the SettingsPane automatically when adding a RadDiagramShape item in a RadDiagram

Regards

Attached Files:
3 comments
ADMIN
Dinko | Tech Support Engineer
Posted on: 01 Mar 2024 13:13

Hi Freddy,

The item is marked as Declined as the reported behavior is not related to our controls.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Freddy
Posted on: 28 Feb 2024 15:52

Hi Nadya

Yes, that Show method can solve my issue. Thanks a lot for the suggestion.

Regards

ADMIN
Nadya | Tech Support Engineer
Posted on: 15 Feb 2024 13:03

Hello, Freddy,

By default, the button shows the SettingsPane when the user clicks with the mouse over the button. Internally, the Click event is handled, and the SettingsPane.Show method is called by passing a location through MouseEventArgs. However, when you call the PerformClick() the MouseEventArgs are missing. If I understand you correctly, you want to display the SettingsPane automatically when adding a RadDiagramShape item in a RadDiagram.

To achieve this, you can directly call the Show method, instead of access the additionalContent button and simulating a click event. You can use the following code snippet to automatically show the settings page when a shape is added on your btnAddField_Click:

this.radDiagram1.DiagramElement.SettingsPane.Show(((MouseEventArgs)e).Location, this.radDiagram1.DiagramElement);

Can you give this solution a try and let me know how it works for you? I believe it would be more convenient for you. 

I am looking forward to your reply.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.