代码以xml文件中的值填充组合框 [英] code to populate a combobox with values from an xml file

查看:69
本文介绍了代码以xml文件中的值填充组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用xml文件中的值填充组合框。

How to populate combobox with values from an xml file.

推荐答案

您将必须从文件中读取数据,并且可以使用诸如dataset.ReadXML()之类的东西,然后使用

You will have to read in the data from the file and you can use something like dataset.ReadXML() and then use that to set your binding for your combobox.

这里是一个让您入门的示例。 http://www.codeproject.com/KB/cs/dropdownfromxml.aspx

Here is an example to get you started. http://www.codeproject.com/KB/cs/dropdownfromxml.aspx

更新:请注意,有两个DataGrid类。带有DataBind()方法的代码位于System.Web.UI.WebControls命名空间中。 Windows窗体控件不具有DataBind方法,应该在没有该行的情况下工作。请参阅: http://msdn.microsoft.com /en-us/library/system.windows.forms.datagrid.datasource.aspx

Update: Note that there are two DataGrid classes. The one that has the DataBind() method is in the System.Web.UI.WebControls namespace. The windows form control does not hav the DataBind method and should work without that line. See: http://msdn.microsoft.com/en-us/library/system.windows.forms.datagrid.datasource.aspx

这篇关于代码以xml文件中的值填充组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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