1

I am kinda newbie on Visual basic 2010, and wanted to create a chat loader, and i wanted it to read values from a xml table.

This is the code i have used in Vb.

 ChatXml.ReadXmlSchema(My.Application.Info.DirectoryPath & "/../Release/chat.xml")
 ChatXml.ReadXml(My.Application.Info.DirectoryPath & "/../Release/chat.xml")
 ComboBox1.DataSource = ChatXml.Tables
 ComboBox1.DisplayMember = "chat"

And the xml file.

<?xml version="1.0" encoding="utf-8"?>
 <chat>
    <gn>Help</gn>
    <gid>1913106</gid>
    <xc>2336</xc>
    <cn>1500337760</cn>
    <g8>g8</g8>
 </chat>

That i want it to do, is to read the value "gn", and add it to the ComboBox, i am not sure what is wrong, tried the "Google is your friend" and could not find something that worked.

The error i get is this.

Complex DataBinding accepts as a data source either an IList or an IListSource.
enter code here

Not sure, but tried to add data to the Tables in DataSet, but seems i can't get it to work. Any help?

4

1 回答 1

2

您的问题是您正在指示组合框显示聊天表中的所有行,而不是告诉它显示gn聊天表中的所有字段。你需要这样做:

ComboBox1.DataSource = ChatXml.Tables(0)
ComboBox1.DisplayMember = "gn"
于 2012-06-20T18:00:43.583 回答