简体   繁体   中英

c# Form Designer - generated code problem

I have map control on main form. Problem is, when form designer generate code then overrides value of variable (RouteOverlay and MarkerOverlay) with new value and i don't want that.

Before generated code

//Map.cs
RouteOverlay = new GMapOverlay(this, "routes");
MarkerOverlay = new GMapOverlay(this, "markers");

After generated code

//MainForm.designer.cs
this.map1.MarkerOverlay = ((GMap.NET.WindowsForms.GMapOverlay)(resources.GetObject("map1.MarkerOverlay")));
this.map1.RouteOverlay = ((GMap.NET.WindowsForms.GMapOverlay)(resources.GetObject("map1.RouteOverlay")));

Add [DesignerSerializationVisiblity(DesignerSerializationVisiblity.Hidden)] to the properties.
This will completely prevent the designer from saving them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM