Prevent from generating Form.resx

有些话、适合烂在心里 提交于 2019-12-13 13:42:02

问题


I have a form that inherits from another from. In the designer, whenever I adjust something like control size or location, VS auto-generates a resx file for that form. The resx just contains some KeyValuePairs for comboboxes, w/c are unnecessary really since these values are already defined in the parent class.

Aside from this, the designer.cs also gets update w/ inherited properties such as Text, NumericUpDown.Value, DisplayMember, ValueMember, etc, w/c again are already defined in the parent class.

I know the designer.cs is supposed to be update w/ the new location and size, but I don't want it to update other stuff that's inherited from parent class.

Is there a way to prevent this, and just let the designer update the location and size?

UPDATE: I found that the ComboBox.Items.AddRange() gets added to the Designer.cs and .resx file due to binding logic that I have in OnLoad(). This is primarily preventing the designer to load properly when the form is reloaded on the Designer.

I modified OnLoad to run the binding logic only when DesignMode is false.

The form no longer throws errors when reloading the designer, but some of the control properties are still unnecessarily added back to the Designer.cs whenever I change any property via the property dialog.

UPDATE2: Totally prevented the designer from generating unnecessary control properties by applying suggestion here.

Now all that's generated are control location and size.

来源:https://stackoverflow.com/questions/5168136/prevent-from-generating-form-resx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!