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