ScreenTipNeeded Event Handler

4 posts, 0 answers
  1. Jeremy Murtishaw
    Jeremy Murtishaw avatar
    86 posts
    Member since:
    Apr 2009

    Posted 15 Oct 2009 Link to this post

    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
  2. Nick
    Admin
    Nick avatar
    767 posts

    Posted 16 Oct 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jeremy Murtishaw
    Jeremy Murtishaw avatar
    86 posts
    Member since:
    Apr 2009

    Posted 16 Oct 2009 Link to this post

    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
  5. Nick
    Admin
    Nick avatar
    767 posts

    Posted 19 Oct 2009 Link to this post

    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.
Back to Top