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;

    }

  • 相关阅读:
    分页精度
    abp zero core 启动vue项目
    swagger 配置错误
    .net core 3.0配置跨域
    .net core 3.0 swagger
    .net core 3.0一个记录request和respose的中间件
    .net Core3.0 +Nlog+Sqlserver
    .net core 3.0+unit of work (一)
    .NetCore 3.0迁移遇到的各种问题
    open xml 导出excel遇到的问题
  • 原文地址:https://www.cnblogs.com/wwwlzp/p/13207872.html
Copyright © 2011-2022 走看看