Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Handles in C# ?

Handles in C# ?

Scheduled Pinned Locked Moved C#
csharpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kindman_nb
    wrote on last edited by
    #1

    Hey on vb we use Handles to handle code with many controls , Now one C# I want to handle a code with some textboxes keydown event then what can I do .. I feel that vb is more easy in coding than c#

    jooooo

    W L 2 Replies Last reply
    0
    • K kindman_nb

      Hey on vb we use Handles to handle code with many controls , Now one C# I want to handle a code with some textboxes keydown event then what can I do .. I feel that vb is more easy in coding than c#

      jooooo

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      Hi, try simply adding the same event handler to several text boxes using properties window in designer. For furher study, investigate the generated designer.cs code. With a little effort you get the idea what happens at code level. Hope this get's you going. Mika

      K 1 Reply Last reply
      0
      • K kindman_nb

        Hey on vb we use Handles to handle code with many controls , Now one C# I want to handle a code with some textboxes keydown event then what can I do .. I feel that vb is more easy in coding than c#

        jooooo

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, if you have the same event handler for several Controls (either through Designer, or by code), then the event handler can figure out which Control fired the event by looking at the first parameter object sender. Say e.g. all Controls firing this event are Buttons, then simply do Button btn=(Button)sender; and you are holding the Button that fired the event. You may want to be more defensive and use the as instead of a straight cast though. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        Voting for dummies? No thanks. X|


        K 1 Reply Last reply
        0
        • W Wendelius

          Hi, try simply adding the same event handler to several text boxes using properties window in designer. For furher study, investigate the generated designer.cs code. With a little effort you get the idea what happens at code level. Hope this get's you going. Mika

          K Offline
          K Offline
          kindman_nb
          wrote on last edited by
          #4

          thanks my friend and i will check it now

          jooooo

          W 1 Reply Last reply
          0
          • L Luc Pattyn

            Hi, if you have the same event handler for several Controls (either through Designer, or by code), then the event handler can figure out which Control fired the event by looking at the first parameter object sender. Say e.g. all Controls firing this event are Buttons, then simply do Button btn=(Button)sender; and you are holding the Button that fired the event. You may want to be more defensive and use the as instead of a straight cast though. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            Voting for dummies? No thanks. X|


            K Offline
            K Offline
            kindman_nb
            wrote on last edited by
            #5

            thanks my friend you are right to use sender now I'm checking it and thanks for really kinds friends here

            jooooo

            L 1 Reply Last reply
            0
            • K kindman_nb

              thanks my friend you are right to use sender now I'm checking it and thanks for really kinds friends here

              jooooo

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              You're welcome. Enjoy C#! :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              Voting for dummies? No thanks. X|


              1 Reply Last reply
              0
              • K kindman_nb

                thanks my friend and i will check it now

                jooooo

                W Offline
                W Offline
                Wendelius
                wrote on last edited by
                #7

                You're welcome. :) Mika

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups