如何从datagridview编辑并保存新的更改

时间:2015-02-09 12:11:13

标签: c# datagridview edit savechanges

我有一个资源文件,我读取数据并将其加载到网格视图。现在我希望用户能够从网格编辑并单击保存按钮,将其保存为resx的新文件?我怎么做?这是用于读取文件的代码。

oDataSet = new DataSet();
//now am reading the files from the path that is selected
XmlReadMode omode = oDataSet.ReadXml(PathSelection);

for (int i = 0; i < oDataSet.Tables[2].Rows.Count; i++)
{
    string comment = oDataSet.Tables["data"].Rows[i][2].ToString();
    string font = Between(comment, "[Font]","[/Font]");
    string datestamp = Between(comment, "[DateStamp]", "[/DateStamp]");
    string commentVal = Between(comment, "[Comment]", "[/Comment]");

    string[] row = new string[] 
    { 
        oDataSet.Tables["data"].Rows[i][0].ToString(),
        oDataSet.Tables["data"].Rows[i][1].ToString(), 
        font, 
        datestamp, 
        commentVal
    };

    Gridview_Input.Rows.Add(row);

    cboLanguage.Enabled = true;
    btnNewfile.Enabled = true;
}

1 个答案:

答案 0 :(得分:0)

您可以尝试每按一次按钮刷新dataGridView。

datagridviewName.update();
datagridviewName.refresh();