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

ScreenTipNeeded Event Handler

3 Answers 42 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Jeremy Murtishaw
Top achievements
Rank 1
Jeremy Murtishaw asked on 15 Oct 2009, 04:07 PM
Hello,

I've got a couple questions. The first is related to a ScreenTipNeeded Event Handler that I've programmatically added to all of my controls. Essentially, I'm wondering how I can determine what control has invoked the handler using the sender or eventargs variables. In my attempt below, the o variable is null...

        void AllControls_ScreenTipNeeded(object sender, ScreenTipNeededEventArgs e) 
        { 
            RadOffice2007ScreenTipElement screenTip = new RadOffice2007ScreenTipElement(); 
            Control o = sender as Control; 
            string sHelp = "This is help text for " + o.Name; 
            screenTip.CaptionLabel.Text = string.Empty; 
            screenTip.MainTextLabel.Text = sHelp; 
            e.Item.ScreenTip = screenTip; 
        } 

Second, as you may have guessed, the purpose of this is to provide help text for each of my controls on the screen. I've come up with this method of using the screentips, but I was wondering if there was a better or more standardized way for achieving this sort of thing? 
Thanks!
Jeremy

3 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 16 Oct 2009, 09:07 AM
Hello Jeremy Murtishaw,

You can debug your application, add a break point in this event, and then in the Watch window of Visual Studio type sender. Visual Studio will show you the type of the object the sender reference is pointing to.

About your second question, your code is ok. Please refer to our online documentation about more information.

Do not hesitate to write us back if you have further questions. 

Best wishes,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jeremy Murtishaw
Top achievements
Rank 1
answered on 16 Oct 2009, 04:18 PM
I should have figured out the casting of the sender variable your way. I don't know why I assumed it would be a control...

Anyway, in order to get the control, I found that the following works:

ComponentInputBehavior behave = sender as ComponentInputBehavior;
RadControl control = behave.SelectedElement.ElementTree.Control as RadControl;

Thanks,
Jeremy
0
Nick
Telerik team
answered on 19 Oct 2009, 07:41 AM
Hello Jeremy Murtishaw,

Thank you for sharing your code with the community.

Do not hesitate to write us back if you have further questions.

Sincerely yours,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
RibbonBar
Asked by
Jeremy Murtishaw
Top achievements
Rank 1
Answers by
Nick
Telerik team
Jeremy Murtishaw
Top achievements
Rank 1
Share this question
or