如何从数据库中保存和加载属性? [英] How to save and load Properties from database?

查看:112
本文介绍了如何从数据库中保存和加载属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是vb.net的初学者..



如何保存控件的属性?



如果我在设计时删除控件,有人可以请我如何保存控件属性并在运行时加载它吗?



保存控件



Hi, Im a beginner in vb.net..

How do I save the properties of a control?

Can somebody please me how to save the controls properties and load it back in runtime if i delete the controls in design time?

Saving the Controls

 Dim ca As New OleDb.OleDbCommandBuilder(damain)       

Dim dsNewRow As DataRow       

For Each labels As Label In Me.Controls           

dsNewRow = dsmain.Tables("settings").NewRow()           

dsNewRow.Item("Parent") = labels.Parent.ToString           

dsNewRow.Item("Location") = labels.Location.ToString           

dsNewRow.Item("Name") = labels.Name.ToString           

dsNewRow.Item("Text") = labels.Text.ToString    

       

dsmain.Tables("settings").Rows.Add(dsNewRow)           

damain.Update(dsmain, "settings")       

Next       

MsgBox("Success")

推荐答案

你没有。



特别是,即使尝试恢复其中一些也会导致问题:Parent不是一个控件,可以产生任何特别有用的字符串:如果它是一个表单,它将返回完全表单类的限定名称,以及标题栏上显示的文本。这无法帮助您恢复控件!



您不需要对已经是字符串的值使用ToString:例如Name和Text。

你想做什么,你认为这是一个好主意?
You don't.

Particularly, even trying to restore some of those would cause problems: Parent is not a control that produces anything particularly useful as a string: if it is a form, it will return the fully qualified name of the form class, and the text that is displayed on the title bar. This will not help you restore the control!

You do not need to use ToString on values that are already strings: Name, and Text for example.
What are you trying to do, that you think this is a good idea?


ayawg kabalaka dan。 sabotan lang nato na ugma XD
ayawg kabalaka dan. sabotan lang nato na ugma XD


这篇关于如何从数据库中保存和加载属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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