using callout as a tooltip ?

1 Answer 229 Views
Callout
atfat
Top achievements
Rank 1
Iron
Iron
atfat asked on 22 May 2021, 10:59 AM | edited on 22 May 2021, 11:01 AM

Hi, can I use callout control to display additional information, from a datagridview cell instead of a tooltip ?

if yes can u leave a sample please...

thx in advance,

Regards

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 May 2021, 01:02 PM

Hello, Atfat,

You can handle the RadGridView.ToolTipTextNeeded event and instead of specifying the text for the tooltip, you can show programmatically a RadCallout. I have prepared a sample code snippet for your reference: 

        public RadForm1()
        {
            InitializeComponent();

            this.radGridView1.Columns.Add("Id");
            this.radGridView1.Columns.Add("Name");
            for (int i = 0; i < 10; i++)
            {
                this.radGridView1.Rows.Add(i, Guid.NewGuid().ToString());
            }
            this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
             

            label = new RadLabel();
            label.Text = "Telerik";
            callout = new RadCallout();
            callout.AssociatedControl = label; 

           this.radGridView1.ToolTipTextNeeded+=radGridView1_ToolTipTextNeeded;
        }

        private void radGridView1_ToolTipTextNeeded(object sender, ToolTipTextNeededEventArgs e)
        {
              Point pt = this.radGridView1.PointToClient(MousePosition);
            GridDataCellElement cellUnderMouse = this.radGridView1.ElementTree.GetElementAtPoint(pt) as GridDataCellElement;
            if (cellUnderMouse != null)
            { 
                label.Text = cellUnderMouse.Value + "";
                if (callout.CalloutForm.Visible)
                {
                    callout.Close();
                }
                callout.Show(cellUnderMouse);
            }
        }

        RadCallout callout;
        RadLabel label; 
    }

You can extend the RadCallout and the hosted control in order to provide more advanced layout for the callout. You can refer to the following help article demonstrating how to use a UserControl for the callout: https://docs.telerik.com/devtools/winforms/controls/callout/getting-started 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
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/.

atfat
Top achievements
Rank 1
Iron
Iron
commented on 25 May 2021, 04:11 AM

thank you very much Dess...
Tags
Callout
Asked by
atfat
Top achievements
Rank 1
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or