0

嗨,我遇到了一个需要帮助的问题。首先,我在这里有一个 XML 文件

    <data>
<row>
  <id>1</id>
  <description>description 1</description>
  <thedate>2013-06-12T00:00:00</thedate>
  <somenotes>some notes1asdsadsadsad</somenotes>
</row>
<row>
  <id>2</id>
  <description>description 2</description>
  <thedate>2013-06-15T00:00:00</thedate>
  <somenotes> </somenotes>
</row>
<row>
  <id>3</id>
  <description>description 3</description>
  <thedate>2013-06-21T00:00:00</thedate>
  <somenotes>bobobobojkfjh</somenotes>
</row>
<row>
  <id>4</id>
  <description>description 4</description>
  <thedate>2013-06-17T00:00:00</thedate>
  <somenotes>adaad</somenotes>
</row>
<row>
  <id>5</id>
  <description>description 5</description>
  <thedate>2013-06-24T00:21:04.803</thedate>
  <somenotes>zcxzc</somenotes>
</row>
<row>
  <id>6</id>
  <description>description 6</description>
  <thedate>2012-12-01T00:00:00</thedate>
  <somenotes>ssss</somenotes>
</row>
<row>
  <id>7</id>
  <description>description 11</description>
  <thedate>2013-05-16T00:21:04.803</thedate>
  <somenotes> </somenotes>
</row>
<row>
  <id>8</id>
  <description>description 21</description>
  <thedate>2013-05-07T00:00:00</thedate>
  <somenotes>notes 2</somenotes>
</row>
<row>
  <id>9</id>
  <description>description 31</description>
  <thedate>2013-01-17T00:00:00</thedate>
  <somenotes> </somenotes>
</row>
<row>
  <id>10</id>
  <description>description 41</description>
  <thedate>2013-01-11T00:00:00</thedate>
  <somenotes> </somenotes>
</row>
<row>
  <id>11</id>
  <description>description 51</description>
  <thedate>2013-06-03T00:00:00</thedate>
  <somenotes> </somenotes>
</row>
<row>
  <id>12</id>
  <description>description 61</description>
  <thedate>2013-06-01T00:00:00</thedate>
  <somenotes>some other notes</somenotes>
</row>
<row>
  <id>13</id>
  <description>desc 55</description>
  <thedate>2013-06-25T00:00:00</thedate>
  <somenotes>aSAdaD

D
Ad
aDa</somenotes>
</row>
<row>
  <id>14</id>
  <description>desc 99</description>
  <thedate>2013-06-24T00:00:00</thedate>
</row>
<row>
  <id>15</id>
  <description>desk 888</description>
  <thedate>2013-05-10T00:00:00</thedate>
</row>
<row>
  <id>16</id>
  <description>test again</description>
  <thedate>2013-05-02T00:00:00</thedate>
  <somenotes>\ad</somenotes>
</row>
</data>

我创建了一个带有 dataGridView 和 testBox 的简单 Windows 窗体应用程序。这是我想做的事情:

  1. 我只想将“id”、“description”和“thedate”元素作为列加载到dataGridView,然后在dataGridView中单击相应单元格时让“somenotes”出现在testBox中

  2. 我还希望能够使用“thedate”元素过滤 dataGridView,以便我可以使用表单上的按钮过滤今天、本周、本月、今年。

对此的任何帮助将不胜感激,因为我对使用带有 c# 的 XML 文件非常缺乏经验。我想以最简单的方式做到这一点,所以没有什么是非常复杂的,再次感谢。

4

1 回答 1

0

1.读取xml到dataTable。

2.将dataGridView的数据源绑定到dataTable。

3.在dataGridView中设置coloumn的显示。

于 2013-07-11T00:23:28.153 回答