VS C# Can't add image to a button in Windows.Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DarkArchon
    New Member
    • Mar 2008
    • 11

    VS C# Can't add image to a button in Windows.Form

    Whenever I try to set the image property of button I get a pop-up error which states
    "An item with the same key has already been added."
    This error also happens whenever I create a new button and try to set the image. I have a feeling the error has something to do with the resources file for the project, any help would be greatly appreciated!!!
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Originally posted by DarkArchon
    Whenever I try to set the image property of button I get a pop-up error which states
    "An item with the same key has already been added."
    This error also happens whenever I create a new button and try to set the image. I have a feeling the error has something to do with the resources file for the project, any help would be greatly appreciated!!!
    If you could provide a code snippet of what you are doing to create the button and assign an image that would help a lot.

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Originally posted by tlhintoq
      If you could provide a code snippet of what you are doing to create the button and assign an image that would help a lot.
      I agree, a snippet of code would really help us.

      Also, could you provide more details about your problem...like. ..
      Are you dynamically creating the button?
      How are you assigning the image?

      Please remember to use Code Tags when posting code.

      -Frinny

      Comment

      • DarkArchon
        New Member
        • Mar 2008
        • 11

        #4
        Well I would post the code except that the problem exists when I am in the designer mode. The error occurs when I click on a button, go to it's properties, and try to choose image ... button.

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Go through your buttons on the page and make sure that you have given names to all of them. Rename them and see if this helps.

          Comment

          • DarkArchon
            New Member
            • Mar 2008
            • 11

            #6
            They all have names, renamed, still have the same problem.

            Comment

            • Curtis Rutland
              Recognized Expert Specialist
              • Apr 2008
              • 3264

              #7
              Well, I saw someone else had the same problem on another site, and here was the resolution:
              Originally posted by other site
              In my case, my project has two resource files. I only have to delete one resource file, and it works.
              So check for that. The resource files are the .resx files.

              Comment

              • DarkArchon
                New Member
                • Mar 2008
                • 11

                #8
                well I had 2 resource files, I deleted one of them, recompiled and everything. the problem still persists.

                Comment

                • Curtis Rutland
                  Recognized Expert Specialist
                  • Apr 2008
                  • 3264

                  #9
                  Maybe you deleted the wrong one? I'm out of ideas :(

                  Comment

                  • DarkArchon
                    New Member
                    • Mar 2008
                    • 11

                    #10
                    Unfortunately not. Although after checking, i find I get the same problem with labels and stuff. I wish there was a more info in the error than just 'item'

                    Comment

                    • Curtis Rutland
                      Recognized Expert Specialist
                      • Apr 2008
                      • 3264

                      #11
                      How big is your project, and how far along are you? Would it be possible for you to start a new project and remake it? Copy and paste might be helpful.

                      Wish I had more help to give you.

                      Comment

                      Working...