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

ToolTipTextNeeded - when is it executed?

8 Answers 275 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Den Duze
Top achievements
Rank 1
Den Duze asked on 23 Feb 2017, 09:45 AM
Hi,

I use a RadGridView to display my data.
When hovering over the first cell of the first row I show a picture (with Telerik.WinControls.UI.RadOffice2007ScreenTipElement control) by the value of a field in the underlying datasource.
This works fine.

The problem is when I scroll down and I hover again over the first cell of the first row, then I get the same picture (what is wrong because it should be another picture).
I noticed that the ToolTipTextNeeded event doesn't fire anymore for this first row.
When I hover over the first cell of another row (where the ToolTipTextNeeded event has not been fired yet) then it works fine.
So I guess that the ToolTipTextNeeded event only fires if there is not yet a tooltip assigned to that cell.
If that is the case, this is very good because then the picture does not to be rendered all the time but when it's another record that is shown in a row where the tooltip is already set then I would like that the ToolTipTextNeeded fires again
I guess I could do that by setting the GridDataCellElement:Screentip to ? (NULL).
But when can I do that? What event is the best to do this? I tried the scroll-event but it looks like that doesn't fire?
Isn't there some event/property that only fires the first time a particular record from the underlying datasource is shown?

Or I'm i trying to do this in a wrong way?

Remark: isn't there some way to know what events are fired when a form is runned? That way I could try to discover myself what's the best event to do something.

Regards
Didier

8 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 23 Feb 2017, 02:45 PM
Hi Didier,

Please note that ScreenTips are different than the ToolTips. The following articles are showing how they should be used:
Could you please share your current code for showing the ScreenTips? I am asking because I am not sure what approach you are currently using. In general, you can use a single ScreenTip for all cells and just set its properties.  

I am looking forward to your reply.
 
Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Den Duze
Top achievements
Rank 1
answered on 23 Feb 2017, 03:20 PM
Hi Dimitar,

I use the ScreenTip.
I create the ScreenTip in the ToolTipTextNeeded event.
In that TooltipTextNeeded event I look if the column VAblob has some value, if it has I create the ScreenTip (Telerik.WinControls.UI.RadOffice2007ScreenTipElement) with that Image and attach that to the CellElement.
I guess that is the wrong approch and I better just create a ScreenTip (in what event and for what control?) and on some event I assign the Image and attach it to the wanted GridDataCellElement.

Remark: I removed all code that is not important
method private void radGridView1_ToolTipTextNeeded( input sender as System.Object, input e as Telerik.WinControls.ToolTipTextNeededEventArgs ):
    define variable oGridDataCellElement as Telerik.WinControls.UI.GridDataCellElement           no-undo.
    define variable oScreenTip           as Telerik.WinControls.UI.RadOffice2007ScreenTipElement no-undo.
     
    assign oGridDataCellElement = cast(sender, Telerik.WinControls.UI.GridDataCellElement) no-error.
    if error-status:error then return. /* move over empty grid or columnheaders */
     
    if oGridDataCellElement:ColumnInfo:Name ne "VAblob" then return.
 
    assign oScreenTip                                            = new Telerik.WinControls.UI.RadOffice2007ScreenTipElement()
                oScreenTip:MainTextLabel:Image      = new System.Drawing.Bitmap(oGridDataCellElement:Image, 200, 200)
                oScreenTip:CaptionLabel:Text           = "Test ScreenTip"
                oGridDataCellElement:ScreenTip      = oScreenTip.
            
    return.
  end method.

regards
Didier
0
Den Duze
Top achievements
Rank 1
answered on 23 Feb 2017, 03:22 PM
Sorry about the alligment, it was OK in the editor but here it's messed up
0
Dimitar
Telerik team
answered on 24 Feb 2017, 09:41 AM
Hi Didier,

Thank you for writing.

First, you need to use the ScreenTipNeeded event for the screen tips. Then it word be better to assign the image to the GridViewCellInfo object, not the cell element. Here is a complete example for this:
public RadForm1()
{
    InitializeComponent();
    radGridView1.DataSource = GetTable();
    radGridView1.ScreenTipNeeded += RadGridView1_ScreenTipNeeded;
    var image = Image.FromFile(@"c:\img\delete.png");
    foreach (var row in radGridView1.Rows)
    {
        foreach (GridViewCellInfo cell in row.Cells)
        {
            cell.Tag = image;
        }
    }
}
 
RadOffice2007ScreenTipElement screenTip = new RadOffice2007ScreenTipElement();
private void RadGridView1_ScreenTipNeeded(object sender, ScreenTipNeededEventArgs e)
{
    var dataItem = e.Item as GridDataCellElement;
    if (dataItem != null)
    {
        screenTip.CaptionLabel.Text = "Select Employee Name";
        screenTip.MainTextLabel.Image = dataItem.RowInfo.Cells[dataItem.ColumnInfo.Name].Tag as Image;
        dataItem.ScreenTip = screenTip;
    }
}

I hope this will be useful. 

Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Den Duze
Top achievements
Rank 1
answered on 24 Feb 2017, 01:05 PM
Hi Dimitar,

I tried this (some variant of this because my images ar already available in the underlying dataSource) but I did not work.

So In the constructor, after the initializeComponents I create an instance of the RadOffice2007ScreenTipElement:
assign oScreenTip = new Telerik.WinControls.UI.RadOffice2007ScreenTipElement().

 

Then in the ScreenTipNeeded method I do:

method private void radGridView1_ScreenTipNeeded( input sender as System.Object, input e as Telerik.WinControls.ScreenTipNeededEventArgs ):
  define variable oGridDataCellElement as Telerik.WinControls.UI.GridDataCellElement           no-undo.
   
  assign oGridDataCellElement = cast(e:item, Telerik.WinControls.UI.GridDataCellElement) no-error.
  if error-status:error then return. /* move over empty grid or columnheaders */
  if oGridDataCellElement:ColumnInfo:Name ne "VAblob" then return.
 
  assign oScreenTip:MainTextLabel:Image    = new System.Drawing.Bitmap(oGridDataCellElement:Image, 200, 200)
              oScreenTip:CaptionLabel:Text      = "Test Tooltip"
              oGridDataCellElement:ScreenTip    = oScreenTip.
       return.
 end method.

Are you sure this should work?
I go through the whole method and then the event fires again (so it looks like the ScreenToolTip is not set)

Update: when the event fires, and I show a message to the user, while the message is shown I move the cursor out of the form then - after clicking OK on the message - the ScreenToolTip is shown???
What can be the reason of that because it lokks like the code and the ScreenToolTip are working fine but as long as my cursor is in the RadGridView teh ScreenToolTip is not shown?

Regards
Didier

0
Dimitar
Telerik team
answered on 27 Feb 2017, 12:15 PM
Hello Didier,

How are you assigning the image to the cell? 

Please note that the message is a modal dialog and it breaks the normal program flow. The code in the main form would not execute until the message is closed, this is why this event is not suitable for such messages.

Could you please remove the message and check if everything works fine without it?

I am looking forward to your reply.
 
Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Den Duze
Top achievements
Rank 1
answered on 10 Mar 2017, 01:31 PM

Hi Dimitar,

Finally got the time to work further on this.
Strange, now it looks like it works (without changing anything to my code).
Great ...

I will report back if the problem should come back

 

Thanks

0
Dimitar
Telerik team
answered on 13 Mar 2017, 10:24 AM
Hello Didier,

I am glad that this is working fine now. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Den Duze
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Den Duze
Top achievements
Rank 1
Share this question
or