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