• 微软原版系统

  • 一键重装系统

  • 纯净系统

  • 在线技术客服

魔法猪系统重装大师 一键在线制作启动 U 盘 PE 系统 用一键重装的魔法拯救失去灵魂的系统
当前位置:首页 > 教程 > 电脑教程

一个DataGrid组例子

时间:2015年04月02日 15:41:03    来源:魔法猪系统重装大师官网    人气:17041

namespace ITMBA.BusinessRules.CommonBaseClassBR.Dock
{
using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data.SqlClient;

///


/// DataGridBR重写了DataGrid组件
///

public class DataGridBR : System.Windows.Forms.DataGrid
{
//创建数组
private System.Windows.Forms.DataGrid [] _DataGrid;
private System.Windows.Forms.Form tempForm;

//DataGrid索引
private int _index = 0;

//设置当前操作DataGrid索引
private int _CurrentIndex=0;

//当前选择值
private DataView _ParentDV;//操作的父DataGrid的视图
private int _ParentRow;//操作的父DataGrid的行索引
private int _ParentColumn;//操作的父DataGrid的列索引

///
/// 操作的父DataGrid的视图
///

public DataView ParentDV
{
get
{
return _ParentDV;
}
set
{
_ParentDV = value;
}
}

///
/// 操作的父DataGrid的行索引
///

public int ParentRow
{
get
{
return _ParentRow;
}
set
{
_ParentRow = value;
}
}

///
/// 操作的父DataGrid的列索引
///

public int ParentColumn
{
get
{
return _ParentColumn;
}
set
{
_ParentColumn = value;
}
}


///
/// 构造函数
///

/// 容器窗口
/// 当前操作的视图
/// 选择的行索引
/// 选择的列索引
/// 将创建DataGrid数目
public DataGridBR(System.Windows.Forms.Form owner,DataView dv,int row,int column, int Num)
{
_DataGrid = new DataGrid[Num];
for(int i=0;i_DataGrid[i] = new DataGrid();
}
tempForm = owner;
ParentDV = dv;
ParentRow = row;
ParentColumn = column;
}

///
/// 当前操作DataGrid索引
///

public int CurrentIndex{
set{
_CurrentIndex = value;
}
get{
return _CurrentIndex;
}
}

///
/// 初始化数据源
///

/// 数据源
public void AddSource(System.Data.DataView dv){
if(dv.Count>0){
_DataGrid[_index++].DataSource = dv;
}
}

///
/// 取得已创建的DataGrid数目
///

///
public int GetNumEntries(){
return _index;
}
///
/// 允许数组式访问
///

public System.Windows.Forms.DataGrid this[int index]{
get{
_DataGrid[index].Dock = DockStyle.Fill;
_DataGrid[index].RowHeadersVisible = true;
_DataGrid[index].CaptionVisible = false;
_DataGrid[index].DoubleClick += new System.EventHandler(this.DataGridBR_DoubleClick);
return _DataGrid[index];
}
set{
_DataGrid[index] = value;
}
}

///
/// 选择事件
///

///
///
private void DataGridBR_DoubleClick(object sender, System.EventArgs e)
{
DataView tempDV = (DataView)_DataGrid[CurrentIndex].DataSource;
int Count = tempDV.Count;
if(Count != 0)
{
//MessageBox.Show(_DataGrid[CurrentIndex].CurrentRowIndex.ToString());
int tempNo = _DataGrid[CurrentIndex].CurrentRowIndex;
DataSet ds = tempDV.Table.DataSet;
//MessageBox.Show(ds.Tables[0].Rows[tempNo][0].ToString());
DataSet ds0 = ParentDV.Table.DataSet;
ds0.Tables[0].Rows[ParentRow][ParentColumn] = ds.Tables[0].Rows[tempNo][0].ToString();
//MessageBox.Show("row:"+ParentRow.ToString()+",column:"+ParentColumn.ToString());
tempForm.Close();
}
else
{
MessageBox.Show("没有记录被选中","信息提示",MessageBoxButtons.OK);
}
}

}
}

一个,DataGrid,组,例子,namespace,
栏目:电脑教程 阅读:1000 2023/12/27
Win7教程 更多>>
U盘教程 更多>>
Win10教程 更多>>
魔法猪学院 更多>>

Copyright © 2015-2023 魔法猪 魔法猪系统重装大师

本站发布的系统仅为个人学习测试使用,请在下载后24小时内删除,不得用于任何商业用途,否则后果自负,请支持购买微软正版软件。

在线客服 查看微信 返回顶部