1、调出 TreeView控件 或  ListBox控件

  private void deductGrid1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex < || e.RowIndex < )
return; if (e.ColumnIndex == || e.ColumnIndex == || e.ColumnIndex == )
{
Rect = deductGrid1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
this.TvEmp.Size = new Size(,);
TvEmp.Location = new Point(Rect.X, Rect.Y);
TvEmp.Visible = true; }
else
{
TvEmp.Visible = false;
}
if (e.ColumnIndex == || e.ColumnIndex == || e.ColumnIndex == )
{
Rect = deductGrid1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
this.cmb.Size = new Size(Rect.Width , * Rect.Height);
cmb.Location = new Point(Rect.X, Rect.Y + Rect.Height);
cmb.Items.Clear();
cmb.Items.Add("是");
cmb.Items.Add("否");
//this.cmb .Size = new Size(Rect .Width ,Rect .Height);
//cmb.Location = new Point(Rect.X, Rect.Y);
cmb.Visible = true; }
else
{
cmb.Visible = false;
}
}

2、处理TreeView控件 选择内容赋值到单元格内

private void TvEmp_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (TvEmp.GetNodeAt(e.X, e.Y) == null) return;
if (TvEmp.GetNodeAt(e.X, e.Y).Level < )
{
dqlib.ShowExclamation("请选择有效的信息!");
return;
}
if (deductGrid1.CurrentCell .ColumnIndex- == )
{
deductGrid1.Rows[deductGrid1.CurrentRow.Index].Cells["EmpOne"].Value = TvEmp.GetNodeAt(e.X, e.Y).Tag;
deductGrid1.CurrentCell.Value = TvEmp.GetNodeAt(e.X, e.Y).Text;
}
if (deductGrid1.CurrentCell.ColumnIndex - == )
{
deductGrid1.Rows[deductGrid1.CurrentRow.Index].Cells["EmpTwo"].Value = TvEmp.GetNodeAt(e.X, e.Y).Tag;
deductGrid1.CurrentCell.Value = TvEmp.GetNodeAt(e.X, e.Y).Text;
}
if (deductGrid1.CurrentCell.ColumnIndex - == )
{
deductGrid1.Rows[deductGrid1.CurrentRow.Index].Cells["EmpThree"].Value = TvEmp.GetNodeAt(e.X, e.Y).Tag;
deductGrid1.CurrentCell.Value = TvEmp.GetNodeAt(e.X, e.Y).Text;
}
//deductGrid1.CurrentCell.Value = TvEmp.GetNodeAt(e.X ,e.Y).Text;
//deductGrid1.CurrentCell.Tag = TvEmp.GetNodeAt(e.X, e.Y).Tag; TvEmp.Visible = false;
}

3、处理ListBox控件

private void cmb_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmb.SelectedItem != null)
{
this.deductGrid1.CurrentCell.Value = this.cmb.SelectedItem.ToString();
this.cmb.Visible = false;
} }

4、处理文本框

private void dgvWeight_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex < 0 || e.RowIndex < 0)
return; if (e.ColumnIndex == 9)
{
Rectangle Rect = dgvWeight.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
this.textBox9.Size = new Size(Rect.Width, Rect.Height); textBox9.Location = new Point(Rect.X, Rect.Y);
textBox9.Visible = true;
textBox9.Focus();
GetRowIndex = e.RowIndex;
}
else
{
textBox9.Visible = false;
}
}

  

C# 在DataGridView中,点击单元格调出 TreeView控件 或 ListBox控件的更多相关文章

  1. C# DataGridView中指定的单元格不能编辑

    注意:DataGridView控件是从.NET Framework 2.0版本开始追加的. ReadOnly属性的使用 DataGridView内所有的单元格不能编辑 当DataGridView.Re ...

  2. 【VBA】点击工作簿中的每个单元格,整行整列变色

    需求描述 在点击单元格的时候,单元格所在行与列都变色显示 实现方案 打开Excle表格,按住ALT+F11 双击上图中的ThisWorkbook Private Sub Workbook_SheetS ...

  3. Easyui之datagrid实现点击单元格修改单元格背景颜色

    前段时间有个需求中有点击datagrid的单元格实现某种事件,调用datagrid的onclickCell这个方法很容易实现,但是体验不好啊,完全不知道自己刚才点击的是哪个单元格,然后就尝试单击单元格 ...

  4. c#DataGridView数据绑定示例——格式化单元格的内容(转)

    转自http://blog.csdn.net/testcs_dn/article/details/37834063 c#DataGridView数据绑定示例 格式化单元格的内容 在使用DataGrid ...

  5. iOS开发UI篇—在UITableview的应用中使用动态单元格来完成app应用程序管理界面的搭建

    iOS开发UI篇—在UITableview的应用中使用动态单元格来完成app应用程序管理界面的搭建 一.实现效果 说明:该示例在storyboard中使用动态单元格来完成. 二.实现 1.项目文件结构 ...

  6. 在DBGrid中,单击单元格选择整行,双击又可编辑单元格

    在设计过程中,有时候数据较大量,field 较多的时候,只是点击单元格可能会对某个field的数据误操作(如数据错行),为此才会想到这个问题,解决办法如下:点击单元格就改当前行颜色. 首先DBGRID ...

  7. C# 获取Excel中的合并单元格

    C# 获取Excel中的合并单元格 我们在制作表格时,有时经常需要合并及取消合并一些单元格.在取消合并单元格时需要逐个查找及取消,比较麻烦.这里分享一个简单的方法来识别Excel中的合并单元格,识别这 ...

  8. excel中,一系列单元格中包含某一个字段的单元格数量?

    excel中,一系列单元格中包含某一个字段的单元格数量?这个怎么写公式?如:A列单元格A1-A7的内容分别为 A.AB.BC.AC.CD.AD.EA,怎么数这一列中几个单元格的内容包含A字母? 任意单 ...

  9. Excel 2010 Alt+; (分号) --- “只选定当前选定区域中的可视单元格”

    excel怎样把筛选出来的加上颜色? 1.选中筛选结果数据区域: 2.同时按下Alt+; (分号)键,选中筛选出的数据: 3.鼠标右键,设置单元格格式: 4.在弹出的对话框中,设置字体.背景颜色,即可 ...

随机推荐

  1. docker mysql5.7.16 中文乱码

    有部分同学会遇到,在centos上Docker-MySQL没乱码,但是在fedora系统上的docker-mysql会有乱码问题,这兴许是docker-mysql的问题,这里的bug我们不去追究,这里 ...

  2. 本地开启https服务

    ### ##自签名证书 ##配置Apache服务器SSL ##自己作为CA签发证书 ###这里是OpenSSL和HTTPS的介绍 OpenSSL HTTPS 开启HTTPS配置前提是已在Mac上搭建A ...

  3. Python-rediscluster客户端

    # -*- coding: UTF-8 -*- import redis import sys from rediscluster import StrictRedisCluster #host = ...

  4. linux记录每次登陆的历史命令

    编辑/etc/profile,增加如下代码 #Record history operation USER_IP=`>/dev/null |awk '{print $NF}' |sed -e 's ...

  5. 【最简单的vim教程】vim学习笔记-基础操作

    说明 C-字母 = Ctrl + 字母 char = 任意字符 开始编辑 insert 按键 功能 说明 i(I) insert 当前位置插入(当前行前) a(A) append 当前字符后面插入(当 ...

  6. Spring Security基于Oauth2的SSO单点登录怎样做?一个注解搞定

    一.说明 单点登录顾名思义就是在多个应用系统中,只需要登录一次,就可以访问其他相互信任的应用系统,免除多次登录的烦恼.本文主要介绍 同域 和 跨域 两种不同场景单点登录的实现原理,并使用 Spring ...

  7. 安装Kubernetes集群时遇到的问题及解决方法

    在搭建Kubernetes集群时遇到一些问题,记录在这里. 搭建过程在另一篇文章:VirtualBox上使用kubeadm安装Kubernetes集群 1. 虚拟机安装完CentOS7登录时遇到war ...

  8. pem文件转换pub

    security CRT在key登陆的时候只能使用.pub文件,所以需呀将.pem转换成.pub 生成公密钥 .pub 文件.ssh-keygen -e -f key.pem >> key ...

  9. session和el表达式

    2015/1/21 ## 回顾昨天案例 ## # 模拟购物车: >> 基本步骤: |-- 显示所有的书籍: |-- 制作书记列表/模仿数据库: |-- 参见昨天示例: |-- 制作查看详情 ...

  10. HTML5历史管理状态机制

    前言:想要不刷新页面同时改变url 可以用HTML5 window对象的 hashChange 事件.同时介绍两个相关的api 和 1个事件. 两个API:1.history.pushState({n ...