简体   繁体   English

VB.NET组合框的持久性?

[英]VB.NET combobox persistence?

I'm fairly new to VB.NET, and I've mainly been doing ASP programming up 'til now, and I have a pretty simple question. 我是VB.NET的新手,直到现在我一直主要在进行ASP编程,我有一个非常简单的问题。

I'm creating a program that will copy a selected file to a selected directory, and I want to store recent files/dirs so that they can be selected from a combo box. 我正在创建一个程序,它将选定的文件复制到选定的目录,并且我想存储最近的文件/目录,以便可以从组合框中选择它们。 I was planning to just create a settings with "files" and "dirs", and just store the strings as | 我打算只使用“文件”和“目录”创建设置,并将字符串存储为| separated values (since that's an illegal file character). 分隔值(因为这是非法文件字符)。

Is there anything wrong with this approach, or are there any better methods? 这种方法有什么问题,还是有更好的方法?

I think your approach is fine as it seems to be simply a local cache of recent directories. 我认为您的方法很好,因为它似乎只是最近目录的本地缓存。 You can persist the data in the application at the module level(create a module with a public object essentially is a global variable) but it goes away when the application is terminated. 您可以在模块级别将数据持久化在应用程序中(使用公共对象创建模块本质上是全局变量),但是在终止应用程序时数据将消失。

This article is using a similar approach to what you were thinking although the example is in C# 尽管示例在C#中,但本文使用的方法与您的想法类似。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM