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. Other Discussions
  3. The Weird and The Wonderful
  4. How to determine if button should be shown?

How to determine if button should be shown?

Scheduled Pinned Locked Moved The Weird and The Wonderful
tutorialquestion
16 Posts 12 Posters 2 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 Chris Maunder

    What an idiot. Clearly he should have done.

    button37.Visible = textBox39.BackColor == Color.White && textBox40.BackColor == Color.PapayaWhip;

    cheers, Chris Maunder The Code Project Co-founder Microsoft C++ MVP

    J Offline
    J Offline
    Jarek Kruza
    wrote on last edited by
    #7

    You know what is worst in this situation? That, this was my first thought. Idea of putting background color into the condition fits so perfect in his methodology, that I missed it first.

    B 1 Reply Last reply
    0
    • D David Skelly

      <Homer> Mmmm... papaya whip... </Homer>

      J Offline
      J Offline
      Jarek Kruza
      wrote on last edited by
      #8

      Brilliant! Well, I'm a great The Simpsons fan. I truly heard Homer saying it.

      1 Reply Last reply
      0
      • J Jarek Kruza

        We are dealing with application left by our former developer. I could mention here a lot of things like putting all of the code in one file (15k lines, 680kB), putting all controls on one form and using BringToFront, naming all controls like textBox85, hardcoding the same connection string in three different places, and so on. But criteria if one of the buttons should be shown beats all of it:

        if ((textBox39.BackColor == Color.White) && (textBox40.BackColor == Color.PapayaWhip))
        button37.Visible=true;
        else
        button37.Visible=false;

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #9

        jkruza wrote:

        naming all controls like textBox85

        Yikes! I cannot stand it when people do that. My course I teach, I penalize points from students who name controls in this manner, and people still do it (then they wonder why they receive a lower grade than the grade they think they were going to earn) :laugh:

        "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

        L 1 Reply Last reply
        0
        • P Paul Conrad

          jkruza wrote:

          naming all controls like textBox85

          Yikes! I cannot stand it when people do that. My course I teach, I penalize points from students who name controls in this manner, and people still do it (then they wonder why they receive a lower grade than the grade they think they were going to earn) :laugh:

          "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #10

          Paul Conrad wrote:

          Yikes! I cannot stand it when people do that.

          Not so bad with one or 2... but considering that it is "85" that is a whole lot of tb's and no way to know what is with what or what has been deleted et cetera et cetera. Gives me a headache just thinking about. Man am I glad we have standards. I would like to say people have been fired for less, but that would be a lie. That would be somewhere I would enjoy working though:thumbsup:

          "9 Pregnent woman can not have a baby in 1 month" -Uknown

          1 Reply Last reply
          0
          • J Jarek Kruza

            We are dealing with application left by our former developer. I could mention here a lot of things like putting all of the code in one file (15k lines, 680kB), putting all controls on one form and using BringToFront, naming all controls like textBox85, hardcoding the same connection string in three different places, and so on. But criteria if one of the buttons should be shown beats all of it:

            if ((textBox39.BackColor == Color.White) && (textBox40.BackColor == Color.PapayaWhip))
            button37.Visible=true;
            else
            button37.Visible=false;

            S Offline
            S Offline
            supercat9
            wrote on last edited by
            #11

            naming all controls like textBox85 I wish Microsoft had made it easy (if not default) to have VS ask the name of new objects being created, especially since the text field will get initialized to the default name (so even if the name and text field should be the same, both will have to be keyed in). BTW, any recommendations for the best plug-in for 2005 and 2008 to fix that?

            S 1 Reply Last reply
            0
            • S supercat9

              naming all controls like textBox85 I wish Microsoft had made it easy (if not default) to have VS ask the name of new objects being created, especially since the text field will get initialized to the default name (so even if the name and text field should be the same, both will have to be keyed in). BTW, any recommendations for the best plug-in for 2005 and 2008 to fix that?

              S Offline
              S Offline
              SteveTheThread
              wrote on last edited by
              #12

              Looking at the type of code and namings I would hazard a guess that this might have been taken from code that was decompile using reflector etc. That would be borne out by the use of three hard coded connection strings too. It may have originally been a single constant. Not that this is an excuse or mitigates the situation. Anyone who has to rip code to that extent needs to get a new career! :wtf:

              T 1 Reply Last reply
              0
              • S SteveTheThread

                Looking at the type of code and namings I would hazard a guess that this might have been taken from code that was decompile using reflector etc. That would be borne out by the use of three hard coded connection strings too. It may have originally been a single constant. Not that this is an excuse or mitigates the situation. Anyone who has to rip code to that extent needs to get a new career! :wtf:

                T Offline
                T Offline
                Tristan Rhodes
                wrote on last edited by
                #13

                Even if it was decompiled, that would still mean that all the show / hide conditions are tied to various color settings. Anyone who has to rip code to that extent needs a freaking lobotomy.

                ------------------------------- Carrier Bags - 21st Century Tumbleweed.

                S 1 Reply Last reply
                0
                • J Jarek Kruza

                  We are dealing with application left by our former developer. I could mention here a lot of things like putting all of the code in one file (15k lines, 680kB), putting all controls on one form and using BringToFront, naming all controls like textBox85, hardcoding the same connection string in three different places, and so on. But criteria if one of the buttons should be shown beats all of it:

                  if ((textBox39.BackColor == Color.White) && (textBox40.BackColor == Color.PapayaWhip))
                  button37.Visible=true;
                  else
                  button37.Visible=false;

                  T Offline
                  T Offline
                  Tristan Rhodes
                  wrote on last edited by
                  #14

                  This retina scarring horror jumped out the screen and tried to garrote me with a cheese wire. :omg:

                  ------------------------------- Carrier Bags - 21st Century Tumbleweed.

                  1 Reply Last reply
                  0
                  • T Tristan Rhodes

                    Even if it was decompiled, that would still mean that all the show / hide conditions are tied to various color settings. Anyone who has to rip code to that extent needs a freaking lobotomy.

                    ------------------------------- Carrier Bags - 21st Century Tumbleweed.

                    S Offline
                    S Offline
                    supercat9
                    wrote on last edited by
                    #15

                    Even if it was decompiled, that would still mean that all the show / hide conditions are tied to various color settings. Anyone who has to rip code to that extent needs a freaking lobotomy. I've seen code like that on systems from any era that supported color (it would be rather hard to use such code on a system that didn't). Many types of controls support a 'tag' property which could be pointed to a sensible object including all necessary ancillary information, but some controls don't. If there's no need to serialize the controls, color might not be totally horrible if one used constants named based upon [i]meaning[/i] and explicitly stated in the comments that all values must be unique (I think the use of a Select Case construct somewhere could enforce that requirement). I would consider the following horrible: If ThisThing.Color = Colors.Red Then ThisThing.Delete but I would consider If ThisThing.Color = FlagColors.Deletable Then ThisThing.Delete to be rather less horrible. I would guess that both pieces of source would yield identical compiled code, however, so a disassembler would guess at the former meaning.

                    1 Reply Last reply
                    0
                    • J Jarek Kruza

                      You know what is worst in this situation? That, this was my first thought. Idea of putting background color into the condition fits so perfect in his methodology, that I missed it first.

                      B Offline
                      B Offline
                      BillW33
                      wrote on last edited by
                      #16

                      jkruza wrote:

                      Idea of putting background color into the condition fits so perfect in his methodology, that I missed it first.

                      Doesn't everyone use background colors for their control logic? ;) :laugh: This code probably even works, but see my tag line…

                      Just because the code works, it doesn't mean that it is good code.

                      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