Dictionary<string, string> dic = TaskDAL.GetList(hashId.ToString(), keys);
dataGridView1.DataSource = (from v in dic
                            select new
                            {
                               Key = v.Key,
                               Value = v.Value,
                               time = GetTime(v.Key.Substring(v.Key.LastIndexOf("_") + 1)),
                               str = "hget " + hashId + " " + v.Key
                            }).ToArray();

//这样绑定后,显示的时候,列的宽度可能不是我们想要的样式,所以可以在代码中指定每一列的宽度。
dataGridView1.Columns[
0].Width = 600; dataGridView1.Columns[2].Width = 120; dataGridView1.Columns[3].Width = 250;

 dataGridView绑定Dictionary |Dictionary绑定到DataGridView

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2021-11-06
  • 2022-12-23
  • 2022-02-26
  • 2022-01-17
  • 2021-07-21
  • 2022-12-23
猜你喜欢
  • 2021-11-29
  • 2022-12-23
  • 2021-11-20
  • 2022-02-27
  • 2021-08-29
相关资源
相似解决方案