zoukankan      html  css  js  c++  java
  • datagridview使用总结

    1.使用数据适配器sqldataAdapter填充datagridview

    SqlConnection conn = new SqlConnection("server = ZHANGMING;user id = sa;pwd=!#%@$^;Database=Logic");
                SqlDataAdapter dap = new SqlDataAdapter("SELECT M.[FID] AS 序号 ,M.[FName] AS 姓名,T1.FName AS 民族,T2.FName AS 性别 ,M.[FIDCard] AS 身份证,M.[FBirthday] AS 生日,T3.[FName] AS 学历 ,T4.[FName] AS 状态,M.[FEnrollDate] AS 登记日期 ,M.[FLeaveDate] AS 离职日期,T6.[FName] AS 职位,M.[FPhone] AS 手机,M.[FExtraPhone] AS 备用电话,M.[FAddress] AS 家庭住址 ,T5.[FName] AS 开户银行,M.[FBankID] AS 银行账号 ,M.[FDescription] AS 备注 FROM [Logic].[dbo].[Com_Employee] M LEFT JOIN Com_Submessage T1 ON M.FName = T1.FID LEFT JOIN Com_Submessage T2 ON M.FNation = T2.FID LEFT JOIN Com_Submessage T3 ON M.FEducation = T3.FID LEFT JOIN Com_Submessage T4 ON M.FStatus = T4.FID LEFT JOIN Com_Submessage T5 ON M.FBank = T5.FID LEFT JOIN Com_Submessage T6 ON M.FPosition = T6.FID", conn);
                DataSet myDateSet = new DataSet();
                dap.Fill(myDateSet);
                dataGridView1.DataSource = myDateSet.Tables[0].DefaultView;

    2.设置当前行为选中状态

    datagridview1.currentrow.selected = true;

    3.获取datagridview总的数值

    for(int i = 0 ; i < datagridview1.rowcount; i++)

    {

      for(in j = 0 ; j < datagridview1.columncount; j++)

    {

      str = datagridview1.rows[i].cells[j].values.tostring();

    }

    }

    4.在datagridview的最左方加上checkbox

    DataGridViewCheckBoxColumn newColumn = new DataGridViewCheckBoxColumn();
                    newColumn.HeaderText = "";
                    newColumn.Width = 18;
                    dataGridView1.Columns.Insert(0, newColumn);

    5.

  • 相关阅读:
    小数据池,bytes
    不会的知识总结:
    nginx低版本不支持pathinfo模式,thinkphp针对此问题的解决办法
    备份了一个nginx的虚拟主机配置文件报错
    centos修改ssh端口
    CentOS安装配置Git服务器(gitosis)
    干货CentOS6.5_Nginx1.40_Php5.57_MySQL5.5.35编译安装全记录
    编译升级php
    php源代码安装常见错误与解决办法分享
    兼容IE,Firefox,Opera等浏览器的添加到收藏夹js代码实现
  • 原文地址:https://www.cnblogs.com/armanda/p/2594078.html
Copyright © 2011-2022 走看看