我有我已經由元素組成3只列出了我想插入我的datagridview, 如何將數據添加到datagridview中的特定列?
所以要插入數據我使用了下面的代碼:
IList<string> ruas = new List<string>();
foreach (var element in Gdriver.FindElements(By.ClassName("search-title")))
{
//ruas.Add(element.Text);
table.Rows.Add(element.Text);
}
IList<string> codps = new List<string>();
foreach(var Codpelement in Gdriver.FindElements(By.ClassName("cp")))
{
table.Rows.Add("",Codpelement.Text);
}
IList<string> Distritos = new List<string>();
foreach (var Distritoelement in Gdriver.FindElements(By.ClassName("local")))
{
//Distritos.Add(Distritoelement.Text);
table.Rows.Add("","",Distritoelement.Text.Substring(Distritoelement.Text.LastIndexOf(',') + 1));
}
請問您好,告訴我一個更好的方法,使數據從上到下出現?
謝謝。
更好地創建一個數據表,然後使數據表成爲DGV的數據源。 – jdweng