+ -
当前位置:首页 → 问答吧 → 如何在Form2里显示Form1筛选后的ID

如何在Form2里显示Form1筛选后的ID

时间:2011-12-10

来源:互联网


在form1:

private void Flex_MouseDoubleClick(object sender, MouseEventArgs e)
  {
  if (e.Button == System.Windows.Forms.MouseButtons.Left && Flex.Col == 3 )
  {
  Form2 form2 = new Form2();

  List<KeyValuePair<string, int>> listIdAndName = new List<KeyValuePair<string, int>>();
  for (int intRow = Flex.Rows.Fixed; intRow < Flex.Rows.Count; intRow++)
  {
  if (Flex[intRow, 3] != null)
  {
  int intMark = (int)Flex[intRow, 3];
  if (intMark == 0)
  {
  string strName = (string)Flex[intRow, 2];
  listIdAndName.Add(new KeyValuePair<string, int>(strName, intMark));
  }
  }
  }
  form2.SetData(listIdAndName);
  form2.ShowDialog();
  }
  }

在form2:  

public void SetData(List<KeyValuePair<string, int>> listIdAndName)
  {
  Grid1.Rows.Count = Grid1.Rows.Fixed + listIdAndName.Count;
  for (int i = 0; i < listIdAndName.Count; i++)
  {
  Grid1[i + Grid1.Rows.Fixed, 2] = listIdAndName[i].Key;
  Grid1[i + Grid1.Rows.Fixed, 3] = listIdAndName[i].Value;
  }
  }

现在只能显示筛选后的name 与 mark 列,如何显示ID列呢?
如何在form2的column[1]显示筛选后form1里的ID

作者: zhq5223984   发布时间: 2011-12-10

Dictionary<string, KeyValuePair<string, int>> dic = new Dictionary<string, KeyValuePair<string, int>>();
  dic.Add("id1234", new KeyValuePair<string, int>("cate", 23));
  foreach (KeyValuePair<string, KeyValuePair<string, int>> key in dic)
  {
  Console.WriteLine(string.Concat("ID",key.Key,"NAME",key.Value.Key,"AGE",key.Value.Value));
  }

作者: Tsapi   发布时间: 2011-12-10

相关阅读 更多

热门下载

更多