开发者

WinForms: Implement a settings dialog?

I have a Form with some data like name, favorite food or something, and want to be able to change these in a new form. This settings form should have the开发者_高级运维 standard OK/Cancel/Apply buttons and update the main forms values on apply directly. What's the best way to do this? Thanks


This will not cover the complete approach, but I'd recommend the PropertyGrid control for powerful and fast settings editing, but it might be not so user friendly so it depends what your target user group is. You can keep all your settings in a class with a public property for each setting. When setting the PropertyGrids SelectedObject to an instance of this object you will be able to edit all settings directly. You can use some attributes to control the display of the properties.

You can find a nice tutorial on using this Grid here. Creating a basic Dialog Form with three buttons should be simple. Hope that helps.


Create a class that will store the data. Show the data (perhaps using databinding in the first form and pass the same object to the edit form to initialize the controls in the edit form.

After closing the edit form with OK or Apply write the values of the controls to the data object.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜