dcsimg
Results 1 to 4 of 4

Thread: Usercontrol default Gotfocus and Lostfocus behaviour

  1. #1

    Thread Starter
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,173

    Usercontrol default Gotfocus and Lostfocus behaviour

    i am creating a button User Control DLL, just for practice sake.

    is it possible to provide the default behavior for the Control on the UI.
    Say for Eg
    Control Enter and Leave events shall change the Backcolor property of the button .

    I am writing it in C#
    The averted nuclear war
    My notes:

    PrOtect your PC. MSDN Functions .OOP LINUX forum
    .LINQ LINQ videous
    If some one helps you please rate them with out fail , forum doesn't expects any thing other than this

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    40,341

    Re: Usercontrol default Gotfocus and Lostfocus behaviour

    Thread moved from the 'VB.Net' forum to the 'C#' forum.

  3. #3
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,567

    Re: Usercontrol default Gotfocus and Lostfocus behaviour

    it shouldn't be too hard. As long as you have your actual event working, you can reference the parent container of the button mycontrol.parent and then set the property that way.

  4. #4
    Fanatic Member
    Join Date
    Nov 2016
    Location
    Slovenia
    Posts
    544

    Re: Usercontrol default Gotfocus and Lostfocus behaviour

    That should do It. Just compile and use control from Toolbox:

    Code:
    public class MyButton : Button
        {
           
            protected override void OnMouseEnter(EventArgs e)
            {
                base.OnMouseEnter(e);
    
                BackColor = Color.Red;
            }
    
            protected override void OnMouseLeave(EventArgs e)
            {
                base.OnMouseLeave(e);
    
                BackColor = SystemColors.Control;
            }
    
        }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width