0
我遇到了麻烦,可以通过编程向devexpress网格添加数据。我使用HTML Agility Pack从网站解析数据,并希望将解析的数据添加到网格中。我使用向导在gridcontrol中创建了13列。手动添加数据到gridcontrol devexpress C#
private void buttonGetData_Click(object sender, EventArgs e)
{
string url = @"____";
HtmlWeb web = new HtmlWeb();
HtmlDocument document = web.Load(url);
var node = document.DocumentNode.SelectNodes("//tr[not(@class)]/td[@style='width:1%;' or @class='coef' or (@class='left' and .//a)]");
/*foreach (var innerText in node.Select(row => row.InnerText))
{
gridView1.AddNewRow();
gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["colunmDate"] , innerText);
gridView1.UpdateCurrentRow();
}*/
}
我得到约2000个元素到节点中。在这段代码中,我从节点获取InnerText。评论的代码不起作用(这只是为了测试)。请帮助我将数据添加到DevExpress Grid。谢谢!
我试着用的BindingList但有没有效果(( '公共Coeff进行(字符串日期,字符串时间,串队)01{ this.date =日期; this.time =时间; this.teams =队; }'' – Georgich
的BindingList coeffs =新的BindingList (); { coeffs.Add 的foreach(在node.Select(行=> row.InnerText)变种的innerText)(新Coeff进行(的innerText,的innerText,的innerText) ); } gridControl1.DataSource = coeffs; gridControl1.RefreshDataSource(); }' –
Georgich