开发者

c# Form Designer - generated code problem

开发者 https://www.devze.com 2023-03-25 13:21 出处:网络
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.

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 GMap开发者_StackOverflowOverlay(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.

0

精彩评论

暂无评论...
验证码 换一张
取 消