RadListView adding new event handler

2 posts, 0 answers
  1. Ramazan
    Ramazan avatar
    2 posts
    Member since:
    Jul 2011

    Posted 26 Apr 2013 Link to this post

    I am using Q1 2011 Reporting on VS 2012. I want to add new event to RadListView but I am getting an error. Here is the part of my code. Error line is in bold.

    private Telerik.WinControls.UI.RadListView lvRules;

    private void lvRules_SelectedItemChanged(object sender, ListViewItemEventArgs e)
            {
                ListViewDataItem item = e.Item;
                if (item == null)
                    return;
                DbSpamRule rule = (DbSpamRule)item.Tag;
                Rule2FormObjects(rule);
            }

    this.lvRules.SelectedItemChanged += new Telerik.WinControls.UI.ListViewItemEventHandler(this.lvRules_SelectedItemChanged);

    How can I fix this error?: Cannot implicitly convert type 'Telerik.WinControls.UI.ListViewItemEventHandler' to 'System.EventHandler'

    Any suggestions?



  2. Paul
    Admin
    Paul avatar
    60 posts

    Posted 30 Apr 2013 Link to this post

    Hello Ramazan,

    Thanks for writing.

    In order to use the ListViewItemEventsArgs, you should cast the EventArgs in the event handler to this type. The reason for not providing the ListViewItemEventsArgs as event arguments is that this would break the simple data binding functionality of this property - unfortunately this is how this mechanism works and it expected the standard EventArgs. 

    Here is how to cast the event args:
    private Telerik.WinControls.UI.RadListView lvRules;
      
    private void lvRules_SelectedItemChanged(object sender, EventArgs e)
    {
        ListViewItemEventArgs args = (ListViewItemEventArgs)e;
        ListViewDataItem item = args.Item;
        if (item == null)
            return;
        DbSpamRule rule = (DbSpamRule)item.Tag;
        Rule2FormObjects(rule);
    }
      
    this.lvRules.SelectedItemChanged += new EventArgs(this.lvRules_SelectedItemChanged);

    Hope this helps.

    All the best,
    Nikolay Aleksiev
    the Telerik team

    Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top