如何使用Visual Studio 2010在C#中使用XML文件填充listview? [英] How do i populate listview with a XML file in C# using Visual Studio 2010?

查看:86
本文介绍了如何使用Visual Studio 2010在C#中使用XML文件填充listview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我在使用XML文件填充Listview时遇到问题

我希望在程序启动时将XML加载到列表视图中

这是我拥有的代码

Hi guys

I''m having trouble populating my Listview using a XML file

I want the XML to load in the listview when the program starts

here is the code i have

//should load favourite xml file in favourites list
            System.Xml.XmlDocument loadDoc = new System.Xml.XmlDocument();
            loadDoc.Load(Application.StartupPath + "\\favourites.xml");

            foreach (System.Xml.XmlNode favNode in loadDoc.SelectNodes("/favourites/Item"))
            {
                Trace.WriteLine(favNode.Attributes["url"].InnerText);

                lstFavs.Items.Add(favNode.Attributes["url"].InnerText);

            }



使用跟踪,我看到正在查看xml文件,但未在页面上加载
我需要更改Visual Studio 2010中的属性中的某些设置吗?

为帮助喝彩

我正在使用webbrowser控件来构建儿童网络浏览器,并且尝试在主视图中以列表形式加载喜欢的网站



using trace i see that the xml file is being seen but is not loading on page
is there some setting in properties in visual studio 2010 that i need to change?

cheers for the help

i''m using webbrowser control to build a childs web browser, and i''m trying to load the favourite websites in the listview which is on the main form

推荐答案

这是一个很好的示例,说明如何一起使用ListView和XML.
Here is a good example how to use ListView and XML together.Displaying ListView and XML[^]

I hope this will help you well.


这篇关于如何使用Visual Studio 2010在C#中使用XML文件填充listview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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