在WinForm 开发中经常用到ListView控件绑定显示DataTable数据,下面记录下主要代码:

 

代码
DataTable AccountDt=DT;
if (AccountDt != null)
{
ArrayList ArrList
= new ArrayList();
int i = 1;
foreach (DataRow Dtr in AccountDt.Rows)
{
ListViewItem lvi
= new ListViewItem();
lvi.Tag
= Dtr["AccountId"].ToString();
lvi.Text
= i.ToString();
lvi.SubItems.Add(Dtr[
"AccountName"].ToString());
lstvAccount.Items.Add(lvi);
i
++;
}
}

 

相关文章:

  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
  • 2021-11-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-15
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案