开发者

Save custom control's properties into settings using property binding

开发者 https://www.devze.com 2023-02-27 00:30 出处:网络
I developed a custom control with two datepicker controls with some more function in it. This - and my other custom controls - are stored in a class library, I reference it in my windows forms applica

I developed a custom control with two datepicker controls with some more function in it. This - and my other custom controls - are stored in a class library, I reference it in my windows forms application to use these controls on my forms.

I use .Net settings capabilities to store form control's state by using applicationsettings/propertybinding in visual studi开发者_开发知识库o ide. It works great, but not for my custom controls. How can I change my custom control's properties to be 'saveable'? I can not see custom properties in property binding windows.

E.g. I'd like to save my specialized datetime picker's control selected value selected dates. My control has methods, properties to get/set it, but in my windows forms application I can not see them as a bindable property.

Environment: c#, .net4, visual studio 2010

Thanks!


Decorate them with one of the SettingAttribute types.

There are two flavors out of the box, one for app settings and one for user specific settings. It sounds like you need the ApplicationScopedSettingAttribute:

http://msdn.microsoft.com/en-us/library/system.configuration.applicationscopedsettingattribute.aspx

0

精彩评论

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