嗨,我遇到了一个我需要一些帮助的问题。首先,我在这里有一个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窗体应用程序。这就是我想做的事情:
我只想将“id”,“description”和“thedate”元素作为列加载到dataGridView,然后在dataGridView中单击相应的单元格时,在testBox中出现“somenotes”
我还希望能够使用“thedate”元素过滤dataGridView,以便今天,本周,本月,今年使用表单上的按钮过滤。
< / LI> 醇>任何对此的帮助都将非常感激,因为我对使用c#的XML文件非常缺乏经验。我想以最简单的方式做到这一点,所以没有什么必须非常复杂,再次感谢。
答案 0 :(得分:0)
1.将xml读取到dataTable。
2.将dataGridView的数据源绑定到dataTable。
3.在dataGridView中设置coloumn的显示。