datagridview数据绑定问题~~~~~~~~~~~~~~~~~~~~
string path = @"E:\新建文件夹\App1\App1\XMLFile1.xml";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(path);
XmlNodeList list = xmlDoc.SelectNodes("/LanguageResource/LangType[@lang='zh-CN']/Menu/MenuItem");
dataGridView1.Columns.Add("a", "语种");
foreach (XmlNode menu in list)
{
string title = menu.Attributes["Name"].Value;
dataGridView1.Rows.Add(new string[] { title });
}
我在datagridview上创建了一个名为语种的列可以将XML指定的Name属性导入到这个列
现在想再创个列将另外的属性Text帮到第二列,怎么搞?求大神指定。。。。。
[解决办法]
怎么不能设置颜色呢?
string path = @"E:\新建文件夹\App1\App1\XMLFile1.xml";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(path);
XmlNodeList list = xmlDoc.SelectNodes("/LanguageResource/LangType[@lang='zh-CN']/Menu/MenuItem");
dataGridView1.Columns.Add("a", "语种");
//*************************
dataGridView1.Columns.Add("b", "文本");
foreach (XmlNode menu in list)
{
string title = menu.Attributes["Name"].Value;
//*************************
string text="文本";
dataGridView1.Rows.Add(new string[] { title,text });
}