我有一个XML文件:

    <Database>
    <SMS>
    <Number>+447761692278</Number>
    <DateTime>2009-07-27T15:20:32</DateTime>
    <Message>Yes</Message>
    <FollowedUpBy>Unassigned</FollowedUpBy>
    <Outcome></Outcome>
    <Quantity>0</Quantity>
    <Points>0</Points>
   </SMS>
   <SMS>
    <Number>+447706583066</Number>
    <DateTime>2009-07-27T15:19:16</DateTime>
    <Message>STOP</Message>
    <FollowedUpBy>Unassigned</FollowedUpBy>
    <Outcome></Outcome>
    <Quantity>0</Quantity>
    <Points>0</Points>
    </SMS>
    </Database>

目前我使用该读入一个DataGridView:

public void Read()
        {
            DataSet ds = new DataSet("SMS DataSet");
            XmlDataDocument xmlDatadoc = new XmlDataDocument();
            xmlDatadoc.DataSet.ReadXml(@"C:\Documents and Settings\Administrator\Desktop\RecSmsDB.xml");
            ds = xmlDatadoc.DataSet;
            this.dataGridView1.DataSource = ds;
            this.dataGridView1.DataMember = "SMS";
            this.dataGridView1.Sort(dataGridView1.Columns["DateTime"], ListSortDirection.Descending);
        }

我希望能够仅在具有特定日期时间中XML对象读取。有谁知道这样做的方法吗?目前我试图包括在命名空间,但没有用的多种方法。

帮助不胜感激,

问候。

***编辑:我希望能够动态地在运行时改变显示的数据

有帮助吗?

解决方案

不,我能想到的。但是,您可以读取所有数据到DataSet,然后创建它过滤短信表DataView和网格绑定到,而不是数据表。

其他提示

如果您将数据集到的BindingSource这BindingSource的连接到电网是什么?一个BindingSource的具有过滤性能,您可以输入类似于SQL的表达式。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top