ItemMouseHover When ViewType is DetailsView

4 posts, 0 answers
  1. Timothy
    Timothy avatar
    37 posts
    Member since:
    Nov 2012

    Posted 20 Jul 2013 Link to this post

    I have an issue with when the ItemMouseHover event is fired when the RadListView.ViewType is DetailsView.

    The event only fires when you hover in an area outside the columns (see the attached image). I'm trying to set up a tooltip that displays item specific information when hovering over a row (item). I can get the tooltip create, however, when moving the mouse around it does not change the tooltip (because the event is not being fired) when I hover over the columns in the row. As you can see in the image (sort of) the tooltip still displays the value for the second row even though I'm hovering over the first row.

    I have a sample project if you will tell me how to submit it.
  2. George
    Admin
    George avatar
    500 posts

    Posted 25 Jul 2013 Link to this post

    Hello Timothy,

    Thank you for contacting us.

    You should subscribe to the TooTipTextNeeded event of the RadListView. Then you can set the tooltip to whatever text you need. Please take a look at the code below:
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
     
            new RadControlSpyForm().Show();
     
            this.radListView1.ViewType = Telerik.WinControls.UI.ListViewType.DetailsView;
            var info = new DirectoryInfo(Environment.CurrentDirectory);
            FileInfo[] files = info.GetFiles();
            this.radListView1.DataSource = files;
            this.radListView1.ShowItemToolTips = true;
            this.radListView1.ToolTipTextNeeded += radListView1_ToolTipTextNeeded;
        }
     
        void radListView1_ToolTipTextNeeded(object sender, Telerik.WinControls.ToolTipTextNeededEventArgs e)
        {
            DetailListViewDataCellElement element = sender as DetailListViewDataCellElement;
            if (element != null)
            {
                e.ToolTipText = element.Text;
            }
        }
    }

    Hope this helps, if you have any other questions or comments, please let me know.
     
    Regards,
    George
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Timothy
    Timothy avatar
    37 posts
    Member since:
    Nov 2012

    Posted 25 Jul 2013 Link to this post

    That works great for the DetailsView, thanks.

    Is ItemMouseHover the best way to handle tooltips when the ViewType is set to ListView? I tried to use the ToolTipTextNeeded event for this but the sender object is of type SimpleListViewElement and I couldn't figure out how to determine the row the cursor is over.
  5. George
    Admin
    George avatar
    500 posts

    Posted 30 Jul 2013 Link to this post

    Hi Timothy,

    Thank you for replying.

    Yes, I can confirm that the ItemMouseHover event is the best choice in this case if you want to determine the current row. Here is an example realization of the idea:
    void radListView1_ItemMouseHover(object sender, ListViewItemEventArgs e)
    {
        var item = e.Item;
        var element = this.radListView1.ListViewElement;
        if (element != null)
        {
            for (int i = 0; i < element.Items.Count; i++)
            {
                if (element.Items[i].Equals(item))
                {
                    Console.WriteLine(i); //the row
                }
            }
        }
    }

    Hope this helps, if you have any other questions or comments, please let me know.
     
    Regards,
    George
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top