开发者

.NET managing settings groups

I've created a WinForm control which is responsible for its own layout using its private properties.

There are some controls on each Form and, when the containing form closes, I want each control to save its state (layout positions mostly). Of course I don't want the controls to expose the private properties. My first though has been to use the Properties.Settings in two control's methods: SaveLayout and RestoreLayout.

But then each control would overwrite the previous saved settings, because the user settings are shared.

Is there a way I can persist a variable in the settings, usin开发者_如何学JAVAg a named prefix of some sort?

// This constructor doesn't exist
Properties.Settings setting = new Properties.Settings("control 1");
setting.edgeDistance = 100;
setting.save();

Or

Properties.Settings setting = new Properties.Settings();
setting.edgeDistance("control 1") = 100;
setting.save();

?

Thanks.


Using Settings in C# Toward the bottom of this article is a heading: "Using Alternate Sets of Settings". This should give you what you need


One of the things you could do is add the [SettingsBindable(true)] attribute to the properties you want to save.

This will cause this option in the properties dialog of the control to be able to store the properties in the settings file:

.NET managing settings groups


I think I've solved using the SettingsKey property:

Properties.Settings setting = new Properties.Settings();
setting.SettingsKey = this.name;

Thanks!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜