代码以xml文件中的值填充组合框 [英] code to populate a combobox with values from an xml file
问题描述
如何使用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屋!