保留用户设置 [英] Persist user settings

查看:36
本文介绍了保留用户设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在用户第一次打开应用时保存他的数据,并且不再显示.

I need to save the user's data for the first time he opens the app and never show it again.

假设我需要用户输入他的名字和其他数据,并保存它以便应用程序以后可以使用它.用户输入他的名字,下次他打开应用程序时,他不会被要求再次输入他的名字.应用程序只是进入主屏幕.

Let's say I need the user to enter his first name and other data, and save it so the application can use it later. The user enters his first name, and the next time he opens the application, he doesn't get asked to enter his name again. The application just goes to the main screen.

我该怎么做?

推荐答案

您可以使用应用程序设置.打开项目的属性(解决方案资源管理器中的我的项目),转到设置选项卡,然后进行设置.我假设你叫它FirstName.保留其他所有内容(用户设置、字符串)并保存.

You can use application settings. Open your project's properties (My Project in the Solution Explorer), go to the Settings tab, and make a setting. I'll assume you called it FirstName. Keep everything else as-is (User Setting, String) and save.

现在您可以像使用任何其他属性一样使用此设置,但它会在运行之间保持不变.您可以在 My.Settings 类中找到该属性.第一次设置:

Now you can use this setting just like any other property, except it'll persist between runs. You can find the property in the My.Settings class. To set it the first time:

My.Settings.FirstName = userFirstName

为了以后使用它,它只是 My.Settings.FirstName.

And to use it later, it's just My.Settings.FirstName.

这篇关于保留用户设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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