none
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) RRS feed

  • 问题

  •  private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
            {
                MessageBox.Show("hello");
                strID = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
                XElement xe = XElement.Load(strPath );
                IEnumerable<XElement> elements = from PInfo in xe.Elements("Table")
                                                 where PInfo.Element("XH").Value == strID
                                                 select PInfo;
                foreach (XElement element in elements)
                {
                    stuName.Text = element.Element("XM").Value ;
                    stuSEX.SelectedItem = element.Element("XB").Value;
                    stuID.Text = element.Element("XH").Value ;
                    stuZy.Text = element.Element("ZY").Value;
                    stuZxf.Text = element.Element("ZXF").Value;

                }
                this.Refresh();
            }

    添加了这个事件后但单击单元格没反应

    2014年6月6日 14:55

答案

  • 楼主你说的无效是指连MessageBox.Show("hello");也不会弹出来来吗?如果是的话,楼主看下datagridview的事件列表,看下Mouse下的cellclick有没有你的触发方法名称:

    如果是空那么事件是触发不了的。


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年6月9日 1:50
    版主