从文本文件加载文本框值 [英] Load textbox value from Text File

查看:118
本文介绍了从文本文件加载文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是vs2008的新手
我要开始一个新项目
它有6个文本框
我的问题是
如何从文本文件加载文本框值
像这样
文本文件数据为

I M newbie for vs2008
i m start a new project
it has 6 textboxes
my problem is that
how to load textbox value from text file
like this
text file data is

<name>Alex</name>
<age>22</age>
<address>57, rd street</address>
<city>DC</city>
<state>califonia</state>
<pin>00000</pin>


我想这样加载我的应用程序


I want to load in my application like this

Textbox1.text = "Alex"
Textbox2.text = "22"
Textbox3.text = "57, rd street"
Textbox4.text = "DC"
Textbox5.text = "california"
Textbox6.text = "00000"


预先感谢

推荐答案

这是什么样的项目,作业?在寻求帮助之前,您应该与您的老师交谈并查看您的参考资料,至少至少要尝试这样做.还要假设您的老师可以谷歌搜索并找到您的问题.我认为您无法为此获得报酬,这简直是可耻的事.

XmlDocument类将允许您读取XML文件,您可以使用File.ReadAllText加载它.然后使用XPath选择节点,并使用.NET提供的DOM方法从中读取值.
What sort of project is this, homework ? You should talk to your teacher and look at your reference material, in order to at least try to do this, before asking for help. Also assume your teacher can google and find your question. I assume there''s no way you''re being paid for this, that would be an utter disgrace.

The XmlDocument class will let you read an XML file, you can load it using File.ReadAllText. Then use XPath to select the nodes and read the values out of them using the DOM methods provided by .NET.


您的XML文件没有有效的根节点.除非您遵循文档结构,否则将无法在输入文件上使用XMLReader或XMLDocument或序列化.您可以使用TextReader 读取文件,然后根据需要解析数据并分配回文本框.

这是您的功课吗?在过去的一个月里,您在问同样的问题吗?请先阅读一些书籍,然后再开始编码.
Your XML file is not having a valid root node. Unless you follow the document structure you wont be able to use XMLReader or XMLDocument or Serialization on the input file. You can use TextReader for reading the file, then parse the data as required and assign back to the textbox.

Is this any homework for you? For last one month you are asking the same kind of questions? Please do read some books before jumping into coding.


这篇关于从文本文件加载文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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