zoukankan      html  css  js  c++  java
  • 在datagridview里添加自定义控件列

    1、定义一个控件如:commbox

      

    1. //定义下拉列表框、隐藏控件、在datagridview中添加控件  
    2.        private ComboBox datacmb=new ComboBox();  
    3.       datacmb.Visible = false;  
    4.       this.dataGridView1.Controls.Add(datacmb);  

    2、添加datagridview的CurrentCellChanged事件

      

    1. private void dataGridView1_CurrentCellChanged(object sender, EventArgs e)  
    2.         {  
    3.             try  
    4.             {  
    5.                 if (this.dataGridView1.CurrentCell.ColumnIndex == 4)  
    6.                 {  
    7.                     Rectangle rec = this.dataGridView1.GetCellDisplayRectangle(dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex, false);  
    8.                     datacmb.Left = rec.Left;  
    9.                     datacmb.Top = rec.Top;  
    10.                     datacmb.Width = rec.Width;  
    11.                     datacmb.Height = rec.Height;  
    12.                     datacmb.Visible = true;                    
    13.                 }  
    14.                 else  
    15.                 {  
    16.                     datacmb.Visible = false;  
    17.                 }  
    18.             }  
    19.             catch  
    20.             {  
    21.                 //MessageBox.Show(ex.Message);  
    22.             }  
    23.         }  
     
    参考资料:

    -------------------------------------------------------------------------------------------------------------------------------------------------
    数据库优化
    数据库教程
    数据库实战经验分享博客

    百度云下载

    评测


  • 相关阅读:
    PHP数字补零的两种方法
    php 防跨站表单提交
    PHP字符串压缩
    原生JS实现表单序列化serialize()
    java并发实现原子操作
    Effective java -- 9 并发/序列化
    Effective java -- 8 异常
    Effective java -- 7 通用程序设计
    Effective java -- 6 方法
    Effective java -- 5 枚举和注解
  • 原文地址:https://www.cnblogs.com/longle/p/datagridview.html
Copyright © 2011-2022 走看看