xml到datagridview. [英] xml to datagridview.

查看:69
本文介绍了xml到datagridview.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我是xml的新手.所以请帮我有关从xml文件将数据填充到datagridview中的问题.
这是我的xml示例

hi
i m fairly new to the xml. so please help me regarding filling data in datagridview from a xml file.
here is my xml example

<Table>
  <sentmail>
    <to>xxxxx</to>
    <text>hello world</text>
    <time> 11/28/2012 <time />
    <from> john <from />
  </sentmail>
  <sentmail>
    <to>xxxxx</to>
    <text>hello john </text>
    <time> 11/28/2012 <time />
    <from> charlie <from />
  </sentmail>


好的.现在,我可以使用以下代码将此xml放在datagridview中:


ok. now i can put this xml in datagridview with this code:

dataset ds=new dataset();
XmlReader xmlFile;
xmlFile = XmlReader.Create(@"D:\New Folder\New Folder\sent_mail.xml", new XmlReaderSettings());
ds.ReadXml(xmlFile);
dataGridView1.DataSource = ds.Tables[0];


效果很好.
但我不想在datagridview中填充"from"元素.


it works fine.
but i don''t want to fill "from" element in datagridview. how can i escape this element from being fetched.

推荐答案

2选项,从数据集中删除From元素(从ds.tables [0]中删除该列.列["from"])



将数据绑定到datagridview后,将DGV列的宽度设置为0(dgv.columns [3] .width = 0)
2 Options, remove the From element from the data set (delete the column from ds.tables[0].columns["from"])

or

After the data is bound to the datagridview set the DGV column width to 0 (dgv.columns[3].width = 0)


这篇关于xml到datagridview.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆