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. Winforms Inherited form - Resources

Winforms Inherited form - Resources

Scheduled Pinned Locked Moved C#
csharpwinformsregexoopquestion
12 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.
  • M Offline
    M Offline
    MarkB123
    wrote on last edited by
    #1

    Got an odd one I could do with some advice on... I have a base form all my decendent data entry forms are based on. The base form had some menus defined on it with icons on the various menu options. This means all the child data entry forms have them too. So far so good. I decided to update the icons on the base form, thinking this change would automatically cascade down to all the child forms but no, they don't. When I open the resources file for each child form, they have a separate copy of the icons. Why would this be - surely it defeats the whole point of visual inheritance? Any suggestions on how I can update all the icons on the child forms to match? I can't go through them one by one and manually adjust as I have several hundred forms in the application. Many thanks.

    G OriginalGriffO M 3 Replies Last reply
    0
    • M MarkB123

      Got an odd one I could do with some advice on... I have a base form all my decendent data entry forms are based on. The base form had some menus defined on it with icons on the various menu options. This means all the child data entry forms have them too. So far so good. I decided to update the icons on the base form, thinking this change would automatically cascade down to all the child forms but no, they don't. When I open the resources file for each child form, they have a separate copy of the icons. Why would this be - surely it defeats the whole point of visual inheritance? Any suggestions on how I can update all the icons on the child forms to match? I can't go through them one by one and manually adjust as I have several hundred forms in the application. Many thanks.

      G Offline
      G Offline
      GenJerDan
      wrote on last edited by
      #2

      Did you do a rebuild? Or just recompile?

      We won't sit down. We won't shut up. We won't go quietly away. YouTube, and My Mu[sic], Films and Windows Programs, etc. and FB

      M 1 Reply Last reply
      0
      • G GenJerDan

        Did you do a rebuild? Or just recompile?

        We won't sit down. We won't shut up. We won't go quietly away. YouTube, and My Mu[sic], Films and Windows Programs, etc. and FB

        M Offline
        M Offline
        MarkB123
        wrote on last edited by
        #3

        I've tried both.

        M 1 Reply Last reply
        0
        • M MarkB123

          I've tried both.

          M Offline
          M Offline
          MarkB123
          wrote on last edited by
          #4

          It's really strange - when I create a really simple project with just 2 forms - a parent and inherited child, it behaves correctly.

          1 Reply Last reply
          0
          • M MarkB123

            Got an odd one I could do with some advice on... I have a base form all my decendent data entry forms are based on. The base form had some menus defined on it with icons on the various menu options. This means all the child data entry forms have them too. So far so good. I decided to update the icons on the base form, thinking this change would automatically cascade down to all the child forms but no, they don't. When I open the resources file for each child form, they have a separate copy of the icons. Why would this be - surely it defeats the whole point of visual inheritance? Any suggestions on how I can update all the icons on the child forms to match? I can't go through them one by one and manually adjust as I have several hundred forms in the application. Many thanks.

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #5

            OK, I just tried it: A MainForm and a BaseForm from which it derives. I add a small menu strip to the BaseForm, and assign Image properties to each menu item. Derive the MainForm from BaseForm, and run it: MainForm has the menus, with the correct icons. Check the Image for one of the BaseForm menu items, run it again: the menus are there, and are using the new images. So what am I doing that is different from you?

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            M 1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              OK, I just tried it: A MainForm and a BaseForm from which it derives. I add a small menu strip to the BaseForm, and assign Image properties to each menu item. Derive the MainForm from BaseForm, and run it: MainForm has the menus, with the correct icons. Check the Image for one of the BaseForm menu items, run it again: the menus are there, and are using the new images. So what am I doing that is different from you?

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

              M Offline
              M Offline
              MarkB123
              wrote on last edited by
              #6

              Thanks for the response. I don't know. On my simple test it also worked. But on my application that hundred of forms and a quite complex set of base forms it doesn't work. Really at a loss.

              OriginalGriffO 1 Reply Last reply
              0
              • M MarkB123

                Thanks for the response. I don't know. On my simple test it also worked. But on my application that hundred of forms and a quite complex set of base forms it doesn't work. Really at a loss.

                OriginalGriffO Offline
                OriginalGriffO Offline
                OriginalGriff
                wrote on last edited by
                #7

                Are you running a single project solution, or are these mixed across assemblies?

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                M 1 Reply Last reply
                0
                • OriginalGriffO OriginalGriff

                  Are you running a single project solution, or are these mixed across assemblies?

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                  M Offline
                  M Offline
                  MarkB123
                  wrote on last edited by
                  #8

                  Running across multiple assemblies. I think I may have got to the bottom it. I created a brand new inherited form from the base form and it behaved correctly. On comparing the designer.cs code of the new form with one of my original (problematic) inherited forms, it looks like a load of extra code has been inserted into the code behind the designers. For Example: // // bsiAdd // this.bsiAdd.ImageOptions.Image = ((System.Drawing.Image)(resources.GetObject("bsiAdd.ImageOptions.Image"))); This seems to have also pushed the images into the resx file. If I remove all the bits of code for about 50 menu items then remove the images manually from the resx file then the inheritance seems to work properly. The only thing I can think of which might have caused this is I put a DevExpress SharedImageCollection onto my main window form and I'm thinking that the nature of this control has perhaps caused this. Issue I have now is I have to apply my manual fix to several hundred forms!

                  OriginalGriffO 1 Reply Last reply
                  0
                  • M MarkB123

                    Running across multiple assemblies. I think I may have got to the bottom it. I created a brand new inherited form from the base form and it behaved correctly. On comparing the designer.cs code of the new form with one of my original (problematic) inherited forms, it looks like a load of extra code has been inserted into the code behind the designers. For Example: // // bsiAdd // this.bsiAdd.ImageOptions.Image = ((System.Drawing.Image)(resources.GetObject("bsiAdd.ImageOptions.Image"))); This seems to have also pushed the images into the resx file. If I remove all the bits of code for about 50 menu items then remove the images manually from the resx file then the inheritance seems to work properly. The only thing I can think of which might have caused this is I put a DevExpress SharedImageCollection onto my main window form and I'm thinking that the nature of this control has perhaps caused this. Issue I have now is I have to apply my manual fix to several hundred forms!

                    OriginalGriffO Offline
                    OriginalGriffO Offline
                    OriginalGriff
                    wrote on last edited by
                    #9

                    Intern? Office Junior? Someone you can con into it? :laugh:

                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                    M 1 Reply Last reply
                    0
                    • OriginalGriffO OriginalGriff

                      Intern? Office Junior? Someone you can con into it? :laugh:

                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                      M Offline
                      M Offline
                      MarkB123
                      wrote on last edited by
                      #10

                      Good idea unfortunately, it gets weirder by the minute. If I apply my fix then open the designer and make any change at all to the design surface of the screen and save it, it puts the code back I deleted and re-adds the images back into the resource file!

                      1 Reply Last reply
                      0
                      • M MarkB123

                        Got an odd one I could do with some advice on... I have a base form all my decendent data entry forms are based on. The base form had some menus defined on it with icons on the various menu options. This means all the child data entry forms have them too. So far so good. I decided to update the icons on the base form, thinking this change would automatically cascade down to all the child forms but no, they don't. When I open the resources file for each child form, they have a separate copy of the icons. Why would this be - surely it defeats the whole point of visual inheritance? Any suggestions on how I can update all the icons on the child forms to match? I can't go through them one by one and manually adjust as I have several hundred forms in the application. Many thanks.

                        M Offline
                        M Offline
                        Mycroft Holmes
                        wrote on last edited by
                        #11

                        At a guess it is because you are getting the form from a resource file, the above tests are probably just using an inherited form and not a resource object.

                        Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

                        M 1 Reply Last reply
                        0
                        • M Mycroft Holmes

                          At a guess it is because you are getting the form from a resource file, the above tests are probably just using an inherited form and not a resource object.

                          Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

                          M Offline
                          M Offline
                          MarkB123
                          wrote on last edited by
                          #12

                          I think that is the likely cause since the base form is in a different assembly. It would make sense that VS is trying to make sure the image is still available to the child forms in a different assembly by copying the resource into the resx file. I'll try moving the base form into the same assembly to see if it resolves the issue. Thanks.

                          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