C#:DataGridView控件操作
2020-11-23 08:56
标签:datagridview blog class code tar ext C#:DataGridView控件操作,搜素材,soscw.com C#:DataGridView控件操作 标签:datagridview blog class code tar ext 原文地址:http://www.cnblogs.com/shenchao/p/3713638.html
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
namespace
Common
{
///
/// DataGridView控件操作
///
public
class
CtlDataGridViewOperate
{
private
DataGridView m_dataGridView =
null
;
///
/// DataGridView控件
///
public
DataGridView refDataGridViewControl
{
set
{
m_dataGridView = value;
}
get
{
return
m_dataGridView;
}
}
///
/// 构造函数
///
public
CtlDataGridViewOperate()
{
}
private
static
volatile
CtlDataGridViewOperate m_dgvOpera =
null
;
///
/// 获取DataGridView控件操作类单一实例
///
///
public
static
CtlDataGridViewOperate GetInstance()
{
if
(
null
== m_dgvOpera)
{
m_dgvOpera =
new
CtlDataGridViewOperate();
}
return
m_dgvOpera;
}
///
/// 点击数据网格视图单元格显示对话框
///
/// 要显示的对话框
/// 列头名称
/// 数据网格视图单元格事件参数
public
void
ClickCellShowDlg(Form frm,
string
headerText, DataGridViewCellEventArgs e)
{
if
(e.RowIndex
{
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控件操作
文章链接:http://soscw.com/index.php/essay/22197.html