CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2012
    Posts
    36

    How can I call a Event when user clicks a button.

    Hello,

    I have a application that has a tab control and I change the font and color on form load.

    But now I need to switch the font and color when I user clicks a button event.

    I have 8 of these events, each customized to set different tab font and color.

    tabControl1_DrawItem
    tabControl1_DrawItem2
    tabControl1_DrawItem3

    I just do not know how to make this happen.

    Any help would be great.

    Thanks,

    -Mike

  2. #2
    Join Date
    Jun 2011
    Location
    Buenos Aires, Argentina
    Posts
    130

    Re: How can I call a Event when user clicks a button.

    The simplest way would be to open your form designer, and double click on the button that should perform what you need. That should take you to the button click event handler automatically.

    For more actions, if you select the button from the form designer, you will see a properties panel where you will have a "lightning" shaped button. There you will find every possible event a button can react to.

    If you want to do it programmatically, you can assign a method to the event with something like:
    Code:
    this.pushButton.Click += new EventHandler(pushButton_Click);
    If you TAB a lot VS will take care of almost everything for you.

    Not sure if this is what you meant... but I hope it helps.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured