Results 1 to 5 of 5

Thread: textbox click event

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    textbox click event

    how do I create a textbox click event function in c#? basically, whats the c# equivalent to vb.net's TextBox1_Click().

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: textbox click event

    this.TEXTBOXNAME.Click += after this click Tab key . It will create a delegate and wires up an event handler .This is one of the features C# has over VB.NET in the IDE.

  3. #3
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: textbox click event

    You can also get a list of events in the propertybox in the formdesigner. If you doubleclick the field an eventhandler is created for you.
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: textbox click event

    Indeed. If you look closely the eventhandler assignment for controls you double-click on takes place in the Designer generated code section, so while it looks neater in your part of the code it is actually doing exactly the same thing.

    Code:
    myTextbox.Click += new EventHandler(eventHandler);
    void eventHandler(object Sender, EventArgs e)
    {
        //
    }
    typed that off the top of the head so case might be a bit wrong

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    Re: textbox click event

    thanks.

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