using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms; namespace Common
{
/// <summary>
/// DataGridView控件操作
/// </summary>
public class CtlDataGridViewOperate
{
private DataGridView m_dataGridView = null; /// <summary>
/// DataGridView控件
/// </summary>
public DataGridView refDataGridViewControl
{
set
{
m_dataGridView = value;
}
get
{
return m_dataGridView;
}
} /// <summary>
/// 构造函数
/// </summary>
public CtlDataGridViewOperate()
{
} private static volatile CtlDataGridViewOperate m_dgvOpera = null; /// <summary>
/// 获取DataGridView控件操作类单一实例
/// </summary>
/// <returns></returns>
public static CtlDataGridViewOperate GetInstance()
{
if(null == m_dgvOpera)
{
m_dgvOpera = new CtlDataGridViewOperate();
}
return m_dgvOpera;
} /// <summary>
/// 点击数据网格视图单元格显示对话框
/// </summary>
/// <param name="frm">要显示的对话框</param>
/// <param name="headerText">列头名称</param>
/// <param name="e">数据网格视图单元格事件参数</param>
public void ClickCellShowDlg(Form frm, string headerText, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0 || e.ColumnIndex < 0)
{
return;
}
var clmindx = m_dataGridView.CurrentCell.ColumnIndex;
if (m_dataGridView.Columns[clmindx].HeaderText.Trim() == headerText)
{
var rowCell = m_dataGridView.CurrentCell.Value;
if (rowCell != null)
{
frm.StartPosition = FormStartPosition.CenterScreen;
frm.ShowDialog();
} }
} }
}

C#:DataGridView控件操作的更多相关文章

  1. WinForm开发(5)——DataGridView控件(3)——DataGridView控件操作

    一.禁止用户改变DataGridView的列宽.行高.列头高度 1.// 禁止用户改变DataGridView1的所有列的列宽 DataGridView1.AllowUserToResizeColum ...

  2. DataGridView控件使用大全说明-各种常用操作与高级操作

    DataGridView控件 DataGridView是用于Windows Froms 2.0的新网格控件.它可以取代先前版本中DataGrid控件,它易于使用并高度可定制,支持很多我们的用户需要的特 ...

  3. DataGridVIew控件绑定数据之后的,增、插、删操作

    最开始没有绑定数据,很快就实现了增.插.删操作,可是绑定数据之后,进行这些操作就会报错. 网上对这方面的资料比较少,自己摸索着找到了解决方法,也就是直接对绑定的数据进行操作,这里以DataTable为 ...

  4. Visual Basic 2012 借助DataGridView控件将SQL server2012 数据导入到Excel 2010

    摘  要: SQL Server 2012 数据和Excel 2010之间的连接和数据的传输,本篇文章主要针对的是SQL Server 2012 数据导入到Excel 2010文件中.Excel软件对 ...

  5. Visual Basic 2012 借助DataGridView控件将Excel 2010数据导入到SQL server 2012

    (注:注释的颜色原本为绿色,在这里变为黑色,有点不便,但不会造成阅读影响.放入Visual Basic2012代码编辑器后会还原成绿色.) 摘  要:DataGridView控件作为数据传输的中介,只 ...

  6. winform DataGridView控件判断滚动条是否滚动到当前已加载的数据行底部 z

    http://www.zuowenjun.cn/post/2015/05/20/162.html 判断 DataGridView控件滚动条是否滚动到当前已加载的数据行底部,其实方法很简单,就是为Dat ...

  7. DataGridView控件

    DataGridView控件 DataGridView是用于Windows Froms 2.0的新网格控件.它可以取代先前版本中DataGrid控件,它易于使用并高度可定制,支持很多我们的用户需要的特 ...

  8. [置顶] DataGridView控件---绑定数据方法

             DataGridView控件是在windows应用程中显示数据最好的方式,它只需要几行简短的代码就可以把数据显示给用户,同时又支持增.删.改操作.今天将自己总结的增加数据的方法总结分 ...

  9. winform DataGridView控件开发经验

    1.不让DataGridView控件自动生成列 设置AutoGenerateColumns 为false. dgTicket.AutoGenerateColumns = false; //将自动生成列 ...

随机推荐

  1. 使用OData快速构建REST服务

    OData是微软支持的一种查询标准,它的第四版使用了REST规范,看起来简洁多了.它的最大的特点是可以在客户端自行配制查询条件,使用它构建REST服务时再也不用担心查询的扩展性问题了. 如下是几个简单 ...

  2. [制作实践]一种基于LM2576的多功能开关电源设计

    http://bbs.kechuang.org/read-kc-tid-9837-page-e.html 摘要:本文介绍了一种性价比高.功能丰富的程控开关电源的设计,对基于LM2576控制核心的升.降 ...

  3. android启动之SystemServer启动

    SystemServer是Android系统的核心,APK应用中可以直接交互的大部分系统服务都在该进程中执行,常见的比方WindowManagerServer(Wms).ActivityManager ...

  4. [Asp.net]AspNetPager分页组件

    引言 在基于Asp.net的内网系统中,分页功能是最常用的,用的最多的组件就是AspNetPager. AspNetPager 官网:http://www.webdiyer.com/aspnetpag ...

  5. vue头像上传与文件压缩

    工作中遇到的问题记录:vue开发头像上传组件,后端提供接口,需求为可相册上传,可相机拍摄上传,文件大小限制为2M 需求点分析 移动端调用相册/摄像头实现拍照 图片压缩,当前高像素的相机拍出来的图片都有 ...

  6. Turn any Linux computer into SOCKS5 proxy in one command

    src: http://www.catonmat.net/blog/linux-socks5-proxy/ I thought I'd do a shorter article on catonmat ...

  7. FIS3配置fis-conf.js

    设置规则的配置接口: fis.match(selector, props); 1.添加md5戳:对 js.css.png 图片引用 URL 添加 md5 戳: fis.match('*.{js,css ...

  8. DCI:The DCI Architecture: A New Vision of Object-Oriented Programming

    SummaryObject-oriented programming was supposed to unify the perspectives of the programmer and the ...

  9. pytest文档4-测试用例setup和teardown

    前言 学过unittest的都知道里面用前置和后置setup和teardown非常好用,在每次用例开始前和结束后都去执行一次. 当然还有更高级一点的setupClass和teardownClass,需 ...

  10. 如何使用V7包中ActionBar(Eclipse版)

    转自:http://blog.csdn.net/appte/article/details/11712591 以前3.0以前的版本要使用ActionBar,必须使用国外大牛写的ActionBarShe ...