首页 新闻 会员 周边 捐助

listView1操作问题

0
悬赏园豆:20 [已解决问题] 解决于 2016-04-21 14:01

整体结果往后错了一列,并且备注没有显示出来什么原因?

DBExecute db = new DBExecute();
db.connectionString = "Data Source=192.168.0.193;initial Catalog=xx;User ID =sa;Password=123456";
string sql = "select 序号, 交票日期, 三月, 六月, 十二月, 级别, 代理商名称, 发票名称, 发票号码, 销售经理, 发票金额, 发票种类, 发票税率, 补贴税率, 补贴金额, [1查询时间], [1次查询结果], [2次查询时间], [2次查询结果], [3次查询时间], [3次查询结果], [4次查询时间], [4次查询结果], 备注 from zongbiao ";
DataTable table = db.Getdatable(sql);

listView1.GridLines = true;
listView1.FullRowSelect = true;
listView1.View = View.Details;
listView1.Scrollable = true;
listView1.MultiSelect = false;
listView1.Clear();
if (listView1.Columns.Count < 1)
{
listView1.Columns.Add("序号", 60, HorizontalAlignment.Center);
listView1.Columns.Add("交票日期", 60, HorizontalAlignment.Center);
listView1.Columns.Add("三月", 60, HorizontalAlignment.Center);
listView1.Columns.Add("六月", 60, HorizontalAlignment.Center);
listView1.Columns.Add("十二月", 60, HorizontalAlignment.Center);
listView1.Columns.Add("级别", 60, HorizontalAlignment.Center);
listView1.Columns.Add("代理商名称", 60, HorizontalAlignment.Center);
listView1.Columns.Add("发票名称", 60, HorizontalAlignment.Center);
listView1.Columns.Add("发票号码", 60, HorizontalAlignment.Center);
listView1.Columns.Add("销售经理", 60, HorizontalAlignment.Center);
listView1.Columns.Add("发票金额", 60, HorizontalAlignment.Center);
listView1.Columns.Add("发票种类", 60, HorizontalAlignment.Center);
listView1.Columns.Add("发票税率", 60, HorizontalAlignment.Center);
listView1.Columns.Add("补贴税率", 60, HorizontalAlignment.Center);
listView1.Columns.Add("补贴金额", 60, HorizontalAlignment.Center);
listView1.Columns.Add("1次查询时间", 60, HorizontalAlignment.Center);
listView1.Columns.Add("1次查询结果", 60, HorizontalAlignment.Center);
listView1.Columns.Add("2次查询时间", 60, HorizontalAlignment.Center);
listView1.Columns.Add("2次查询结果", 60, HorizontalAlignment.Center);
listView1.Columns.Add("3次查询时间", 60, HorizontalAlignment.Center);
listView1.Columns.Add("3次查询结果", 60, HorizontalAlignment.Center);
listView1.Columns.Add("4次查询时间", 60, HorizontalAlignment.Center);
listView1.Columns.Add("4次查询结果", 60, HorizontalAlignment.Center);
listView1.Columns.Add("备注", 60, HorizontalAlignment.Center);
}
ListViewItem lvi = new ListViewItem();
for (int i = 0; i < table.Rows.Count; i++)
{
lvi = new ListViewItem();
lvi.SubItems.Clear();
lvi.SubItems.Add(table.Rows[i][0].ToString());
lvi.SubItems.Add(table.Rows[i][1].ToString());
lvi.SubItems.Add(table.Rows[i][2].ToString());
lvi.SubItems.Add(table.Rows[i][3].ToString());
lvi.SubItems.Add(table.Rows[i][4].ToString());
lvi.SubItems.Add(table.Rows[i][5].ToString());
lvi.SubItems.Add(table.Rows[i][6].ToString());
lvi.SubItems.Add(table.Rows[i][7].ToString());
lvi.SubItems.Add(table.Rows[i][8].ToString());
lvi.SubItems.Add(table.Rows[i][9].ToString());
lvi.SubItems.Add(table.Rows[i][10].ToString());
lvi.SubItems.Add(table.Rows[i][11].ToString());
lvi.SubItems.Add(table.Rows[i][12].ToString());
lvi.SubItems.Add(table.Rows[i][13].ToString());
lvi.SubItems.Add(table.Rows[i][14].ToString());
lvi.SubItems.Add(table.Rows[i][15].ToString());
lvi.SubItems.Add(table.Rows[i][16].ToString());
lvi.SubItems.Add(table.Rows[i][17].ToString());
lvi.SubItems.Add(table.Rows[i][18].ToString());
lvi.SubItems.Add(table.Rows[i][19].ToString());
lvi.SubItems.Add(table.Rows[i][20].ToString());
lvi.SubItems.Add(table.Rows[i][21].ToString());
lvi.SubItems.Add(table.Rows[i][22].ToString());
lvi.SubItems.Add(table.Rows[i][23].ToString());

listView1.Items.Add(lvi);
}

低调又不猥琐的提莫的主页 低调又不猥琐的提莫 | 初学一级 | 园豆:8
提问于:2016-04-21 13:53
< >
分享
最佳答案
1

这是因为lvi.Text没有赋值。。 它是第一列。。。

收获园豆:20
waiter | 小虾三级 |园豆:1000 | 2016-04-21 13:58
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册