zoukankan      html  css  js  c++  java
  • 双击dataGridView一行数据,打开一个另一个窗体,并把双击行的数据展示出来

    本文是以list为数据源,双击获取一个list实例,并把这个实例传到另一个窗体,并把所得实例的数据展示出来。

    //  frmEmployeeList.cs

    //dataGridView1双击事件CellDoubleClick

      private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)

            {
                  frmSave f3 = new frmSave();  
                  var visit = this.dataGridView1.CurrentRow.DataBoundItem as EmployeeList;//visit  相当于一个实体
                  f3.DataEntity = visit;
                  f3.Show();    
            }  

    //frmSave.cs

    List<EmployeeList> emp=new List<EmployeeList>();

     public EmployeeList DataEntity
            {
                get
                {
                    return this.m_DataEntity;
                }
                set
                {
                    if (value == null)
                        return;
                        this.m_DataEntity = value;
                        this.DisplayData();     
                }
            }
            EmployeeList m_DataEntity;

    public void DisplayData()

    {

    this.btId.text=this.m_DataEntity.empid;

    this.btAge.text=this.m_DataEntity.empage;

    this.btname.text=this.m_DataEntity.empname;

    }

    //EmployeeList.cs

    public class Employee

    {

    public string empid;

    public in empage;

    public string empname;

    }

  • 相关阅读:
    Linux Shell中的延时函数
    调试core文件(转)
    C++类构造函数初始化列表(转)
    seq简介(转)
    查看内存使用情况(转)
    awk 数组实例(转)
    伪终端(转)
    C++类成员变量的初始化方法(转)
    几个shell命令(转)
    子进程自父进程继承什么或未继承什么(转)
  • 原文地址:https://www.cnblogs.com/wwwlzp/p/13207872.html
Copyright © 2011-2022 走看看