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. How do you name controls?

How do you name controls?

Scheduled Pinned Locked Moved C#
question
6 Posts 4 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.
  • C Offline
    C Offline
    CooperWu
    wrote on last edited by
    #1

    I prefer to 'Hungarian Notation' than 'PascalCase' to named controls. e.g. I like use btnOk, btnCancel, txtName, txtAge but not okButton, cancelButton, nameTextBox, ageTextBox. which one do you like? and why?

    Glad to discuss with you and best wishes.

    V D realJSOPR 3 Replies Last reply
    0
    • C CooperWu

      I prefer to 'Hungarian Notation' than 'PascalCase' to named controls. e.g. I like use btnOk, btnCancel, txtName, txtAge but not okButton, cancelButton, nameTextBox, ageTextBox. which one do you like? and why?

      Glad to discuss with you and best wishes.

      V Offline
      V Offline
      Vikram A Punathambekar
      wrote on last edited by
      #2

      The former, but only with controls. When I need to store the user's name in a string, it's always userName, never strUserName.

      Cheers, Vıkram.


      I've never ever worked anywhere where there has not been someone who given the choice I would not work with again. It's a job, you do your work, put up with the people you don't like, accept there are probably people there that don't like you a lot, and look forward to the weekends.   - Josh Gray.

      C 1 Reply Last reply
      0
      • V Vikram A Punathambekar

        The former, but only with controls. When I need to store the user's name in a string, it's always userName, never strUserName.

        Cheers, Vıkram.


        I've never ever worked anywhere where there has not been someone who given the choice I would not work with again. It's a job, you do your work, put up with the people you don't like, accept there are probably people there that don't like you a lot, and look forward to the weekends.   - Josh Gray.

        C Offline
        C Offline
        CooperWu
        wrote on last edited by
        #3

        Yes, I'll named control like txtUsername, and named variable userName. But now, I have to named control like userNameTextBox... but I don't like...

        Glad to discuss with you and best wishes.

        1 Reply Last reply
        0
        • C CooperWu

          I prefer to 'Hungarian Notation' than 'PascalCase' to named controls. e.g. I like use btnOk, btnCancel, txtName, txtAge but not okButton, cancelButton, nameTextBox, ageTextBox. which one do you like? and why?

          Glad to discuss with you and best wishes.

          D Offline
          D Offline
          DaveyM69
          wrote on last edited by
          #4

          The actual class: MyTextBox The class instance: myTextBox Its properties and events: Text ... TextChanged Why, to follow the convention that is used almost everywhere, and so I can see instantly if I'm working with an instance or a static

          Dave
          BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
          Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

          1 Reply Last reply
          0
          • C CooperWu

            I prefer to 'Hungarian Notation' than 'PascalCase' to named controls. e.g. I like use btnOk, btnCancel, txtName, txtAge but not okButton, cancelButton, nameTextBox, ageTextBox. which one do you like? and why?

            Glad to discuss with you and best wishes.

            realJSOPR Offline
            realJSOPR Offline
            realJSOP
            wrote on last edited by
            #5

            I use buttonOK, checkboxCheckMe, etc. That way, all controls of the same type are grouped in the same place in intellisense. You could take it a step further and maybe use ctlButtonOK, and ctlCheckboxCheckMe, and that would put *all* of the controls in one single group in intellisense, yet still separate the controls by type within the group.

            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

            C 1 Reply Last reply
            0
            • realJSOPR realJSOP

              I use buttonOK, checkboxCheckMe, etc. That way, all controls of the same type are grouped in the same place in intellisense. You could take it a step further and maybe use ctlButtonOK, and ctlCheckboxCheckMe, and that would put *all* of the controls in one single group in intellisense, yet still separate the controls by type within the group.

              "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
              -----
              "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

              C Offline
              C Offline
              CooperWu
              wrote on last edited by
              #6

              John Simmons / outlaw programmer wrote:

              all controls of the same type are grouped in the same place in intellisense.

              Agree with you, especially for the same type control.

              Glad to discuss with you and best wishes.

              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