Visual Basic .NET支持动态属性……
来源:互联网 发布:岁寒而知松柏之后凋也 编辑:程序博客网 时间:2024/05/03 14:34
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
要看动态属性的例子,首先在Visual Basic中创建一个Windows应用程序。添加一个TextBox到默认窗体中;确认TextBox是被选中的,然后在属性窗口中定位Dynamic属性。
点击Advanced标签旁边的省略号按钮,打开一个对话框,该对话框中列出了TextBox所有的属性,选择Text属性,键映射框将会被激活。键映射决定了键储存在配置文件中的值。点击确定关闭对话框。
下面的代码是在InitializeComponent方法中产生的(位于Windows Form设计器产生代码区)。这段代码不能直接修改,只能使用属性窗口。
Dim configurationAppSettings As _
System.Configuration.AppSettingsReader = _
New System.Configuration.AppSettingsReader()
Me.TextBox1.Text = CType( _
configurationAppSettings.GetValue("TextBox1.Text", _
GetType(System.String)), String)
设置储存在一个名为app.cofig的XML格式的文件中。前面的示例代码所产生的XML代码如下:
<?xml version="1.0" encoding="Windows-1252"?>
<configuration>
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="TextBox1.Text" value="TextBox1" />
</appSettings>
</configuration>
当应用程序被编译时,该文件被重命名为assembly.config,这里assembly是你的编译出的应用程序的名字。如果想改变这些值,根本没有必要重新编译程序,只要简单的编辑配置文件在其中修改成相应的值即可。
Visual Basic .NET支持动态属性……';return true">
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
Visual Basic .NET支持动态属性,其动态属性储存在一个应用程序配置文件中,该文件在应用程序执行时将会被读到。使用动态属性可以在不重新编译应用程序的情况下改变一些属性值。你可以使用它们保存数据库连接字符串、应用程序日志信息或者服务器连接信息。 要看动态属性的例子,首先在Visual Basic中创建一个Windows应用程序。添加一个TextBox到默认窗体中;确认TextBox是被选中的,然后在属性窗口中定位Dynamic属性。
点击Advanced标签旁边的省略号按钮,打开一个对话框,该对话框中列出了TextBox所有的属性,选择Text属性,键映射框将会被激活。键映射决定了键储存在配置文件中的值。点击确定关闭对话框。
下面的代码是在InitializeComponent方法中产生的(位于Windows Form设计器产生代码区)。这段代码不能直接修改,只能使用属性窗口。
Dim configurationAppSettings As _
System.Configuration.AppSettingsReader = _
New System.Configuration.AppSettingsReader()
Me.TextBox1.Text = CType( _
configurationAppSettings.GetValue("TextBox1.Text", _
GetType(System.String)), String)
设置储存在一个名为app.cofig的XML格式的文件中。前面的示例代码所产生的XML代码如下:
<?xml version="1.0" encoding="Windows-1252"?>
<configuration>
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="TextBox1.Text" value="TextBox1" />
</appSettings>
</configuration>
当应用程序被编译时,该文件被重命名为assembly.config,这里assembly是你的编译出的应用程序的名字。如果想改变这些值,根本没有必要重新编译程序,只要简单的编辑配置文件在其中修改成相应的值即可。
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- Visual Basic .NET支持动态属性……
- Visual Basic .NET 已不再支持的 Visual Basic 6.0 功能
- 将 Visual Basic 6.0 项目升级到 Visual Basic .NET ItemData 属性
- Visual Basic.net
- Visual Basic .NET 入门
- 精通 Visual Basic .NET
- Mastering Visual Basic .NET
- Visual Basic.NET探密
- Visual Basic.NET探密
- Visual Basic.NET探密
- 什么是Visual Basic.NET?
- Visual Basic.NET探密
- Visual Basic .NET Bible
- Visual Basic.NET 学习心得
- Visual Basic .NET
- VB.NET & Visual Basic
- VB.NET & Visual Basic
- Visual Basic .NET
- 得到指定字符串列表中,指定个数的字符串
- 标题 VS.NET为企业做好了准备吗?
- 关于日期天数计算的几个函数!
- ASP.NET中Cookie编程的基础知识(6)
- 字符串分拆查询
- Visual Basic .NET支持动态属性……
- 如何在SQL Server存储过程中执行DTS包
- ADO .NET简介
- chapter2: 安装 Oracle 软件并构建数据库
- 子窗体刷新父窗体的问题完全解决了,谢谢E版主
- 如何彻底删除Oracle(转载)
- 微软的Net Search 引擎内幕(转)
- 使用ADO.NET轻松操纵数据库
- 在DataSet中查询纪录