tagridviewcheckbox列的复选框值保存到Xml文件

tagridviewcheckbox列的复选框值保存到Xml文件

本文介绍了如何将Datagridviewcheckbox列的复选框值保存到Xml文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个datagridview,它在运行时填充,并有一个CheckBoxColumn作为它的第一列。

当我试图保存的内容没有选择行的datagridview,即没有选中复选框,所有复选框的值应该为FALSE,并且应该写入文件。相反没有提到复选框列,它被省略

例如,文件应保存为:

Hi,
I have a datagridview which is populated at run-time and has a CheckBoxColumn as its first column.
When i am trying to save the contents of the datagridview with no rows selected, i.e. no checkbox selected, the value of all the checkboxes should be FALSE and that should be written to the file. Instead nothing is mentioned about the checkbox column, it is omitted
For example, The file should be saved as :

<?xml version="1.0" standalone="yes"?>
<NewDataSet>
  <Table1>
    <Select>False</Select>
    <Island>AppReplayIp.zip</Island>
    <PortConfig>abc</PortConfig>
    <Time_x0020_Out>200</Time_x0020_Out>
    <Host_x0020_Name>ixin-sovit</Host_x0020_Name>
  </Table1>
</NewDataSet>





而是



But instead

<Table1>
  <Island>AppReplayIp.zip</Island>
  <PortConfig>abc</PortConfig>
  <Time_x0020_Out>200</Time_x0020_Out>
  <Host_x0020_Name>ixin-sovit</Host_x0020_Name>
</Table1>



在这里我们看到sele ct列未写入文件



我写入文件的代码是


Here we see the "select" column is not written to the file

My code for writing to the file is

private void createXML(string filename)
       {
           DataTable dt = new DataTable();
           foreach (DataGridViewColumn col in dgvIsland.Columns)
           {
               dt.Columns.Add(col.HeaderText);
           }
           foreach (DataGridViewRow row in dgvIsland.Rows)
           {
               DataRow dRow = dt.NewRow();
               foreach (DataGridViewCell cell in row.Cells)
               {
                   dRow[cell.ColumnIndex] = cell.Value;
               }
               dt.Rows.Add(dRow);
           }
           DataSet ds = new DataSet();
           ds.Tables.Add(dt);
           ds.WriteXml(filename);
       }





如何解决此问题?是否有任何事件与cell_click相关联?

请帮忙!!! :)



How can i resolve this issue?Should any events be associated with the cell_click or something?
Please help!!! :)

推荐答案

这篇关于如何将Datagridviewcheckbox列的复选框值保存到Xml文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 23:32