C#如何将添加的按钮保存到用户设置 [英] C# how to save added button to user settings

查看:113
本文介绍了C#如何将添加的按钮保存到用户设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在flowlayout面板中创建了一个带有几个按钮的winform。我想在flowlayout面板中添加新按钮并删除现有按钮,并将它们保存到用户设置中,以便下次运行应用程序时,我希望看到对winform进行按钮的更改。关于如何解决这个问题的任何想法?



我尝试过:



我搜索了互联网,但我找不到任何关于按钮的信息,以及如何在添加时将它们保存到用户设置。我在标签文本和按钮名称上找到了解决方案。

I have created a winform with several buttons in a flowlayout panel. I want to add new buttons and delete existing buttons within the flowlayout panel and have them saved to user settings so next time I run application I want to see the changes of buttons made to the winform. Any ideas on how to solve this?

What I have tried:

I searched the internet but I can not find anything about buttons and how to save them to user settings when added. i found solutions on label text and button names.

推荐答案

按钮无法保存 - 它们是一个控件,并且有很多关于按钮的信息每次将特定按钮添加到您的应用程序时,它都会为该特定按钮创建新的工作。

您可以存储有关按钮的信息:文本,顺序以及要添加到的事件的一些指示它,但你不能只是存储按钮然后神奇地重新加载它 - 你必须使用存储的信息来创建一个新的按钮并将其添加到你的收藏中,就像你在用户那时做的那样要求换一个新的。



实际存储机制有很多种:XML,JSON,文本,配置设置,cookie,数据库,本地存储等等 - 甚至是几种的组合 - 取决于您的应用当前的工作方式,以及它的运行环境。例如,基于Web的解决方案与Windows窗体版本有很大不同。
"Buttons" can't be saved - they are a control, and a lot of the information about a button that makes it work is created fresh for that specific button each time it is added to you app.
You can store the information about the button: Text, order, and some indication of what events to add to it, but you can't just "store the button" and then magically "reload" it - you have to use the stored information to create a new button and add it to your collection, exactly as you do at the moment when the user asks for a new one.

Actual storage mechanisms are many and varied: XML, JSON, text, config settings, cookies, databases, local storage, and many others - or even a combination of several - depending on how your app currently works, and the environment in which it operates. As Web based solution for example, would be very different from a Windows Forms version.


这篇关于C#如何将添加的按钮保存到用户设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆