您好,欢迎光临本网站![请登录][注册会员]  
文件名称: MyDataGridMultiHeaderHelp 多表头帮助类
  所属分类: 其它
  开发工具:
  文件大小: 11kb
  下载次数: 0
  上传时间: 2011-01-07
  提 供 者: a13062******
 详细说明: 一、对于MyMulDataGridViewHeader的使用的一个简单的示例 1、数据表 use master go --创建数据库 if exists(select * from sys.sysdatabases where name='TestDB') drop database TestDB go create database TestDB on ( name ='TestDB_data', filename = 'E:\Data\TestDB_data.mdf', size = 5mb, maxsize = 20mb, filegrowth = 10% ) log on ( name ='TestDB_log', filename = 'E:\Data\TestDB_log.ldf', size =3mb, maxsize = 10mb, filegrowth = 1mb ) go use TestDB go if exists(select * from sys.tables where name='UserInfo') drop table UserInfo go create table UserInfo ( id int primary key identity(1,1), uname varchar(20) not null, usex int not null, uage int not null, chineseremark int not null, matchremark int not null, englishremark int not null ) go insert into userinfo values('小谭',1,21,82,90,81) insert into userinfo values('小花',0,21,83,90,82) insert into userinfo values('小华',0,20,84,90,99) insert into userinfo values('小方',0,20,85,92,85) insert into userinfo values('小高',0,21,86,90,88) insert into userinfo values('小宁',1,21,87,90,89) insert into userinfo values('小江',1,21,88,90,92) insert into userinfo values('小艳',0,20,89,90,93) insert into userinfo values('小琼',0,21,92,98,95) go select * from userinfo //后台调用 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; using MyDataGridMultiHeaderHelp; namespace MyTest { public partial class Form3 : Form { public Form3() { InitializeComponent(); } DataGridView dgv = new DataGridView(); private void Form3_Load(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("Server=.;DataBase=TestDB;Uid=sa;Pwd=123456"); SqlCommand cmd = new SqlCommand("select * from userinfo", conn); SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand = cmd; DataSet ds = new DataSet(); sda.Fill(ds); DataTable dt = ds.Tables[0]; //清除原有的控件 if (dgv != null && dgv.Name != "Mydgv") { panel1.Controls.RemoveByKey(dgv.Name); dgv.Dispose(); dgv = null; } dgv = CreateDataGridView(); dgv.DataSource = dt; this.panel1.Controls.Add(dgv); } private MyMulDataGridViewHeader CreateDataGridView() { MyMulDataGridViewHeader dgv = DataIntance.InstanceDataGridView(); DataIntance intance = new DataIntance(dgv); TreeView mytv = new TreeView();//实例树。以树节点为多表头节点 intance.SetData(mytv.Nodes, "学员信息表"); intance.SetData(mytv.Nodes[0].Nodes, "ID编号"); intance.SetData(mytv.Nodes[0].Nodes, "姓名"); intance.SetData(mytv.Nodes[0].Nodes, "性别"); intance.SetData(mytv.Nodes[0].Nodes, "年龄"); intance.SetData(mytv.Nodes[0].Nodes, "成绩"); intance.SetData(mytv.Nodes[0].Nodes[4].Nodes, "语文"); intance.SetData(mytv.Nodes[0].Nodes[4].Nodes, "数学"); intance.SetData(mytv.Nodes[0].Nodes[4].Nodes, "英语"); intance.SetProperty("ID"); intance.SetProperty("uname"); intance.SetProperty("usex"); intance.SetProperty("uage"); intance.SetProperty("chineseremark"); intance.SetProperty("matchremark"); intance.SetProperty("englishremark"); dgv.ColumnTreeView = new TreeView[] { mytv }; dgv.ColumnDeep = 3; return dgv; } } } 二、GridView多表头的使用 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data; using MyDataGridMultiHeaderHelp; namespace MyWeb { public partial class GridViewMulRow : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { GetMulData(); } } private void GetMulData() { SqlConnection conn = new SqlConnection("Server=.;DataBase=TestDB;Uid=sa;Pwd=123456"); SqlCommand cmd = new SqlCommand("select * from userinfo", conn); SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand = cmd; DataSet ds = new DataSet(); sda.Fill(ds); DataTable dt = ds.Tables[0]; this.gvTest.DataSource = dt; this.gvTest.DataBind(); TableCellCollection tcHeader = this.gvTest.HeaderRow.Cells; tcHeader.Clear(); GridViewMulRowHeader gv = new GridViewMulRowHeader(tcHeader); gv.InstanceTableCell("学员信息表", "colspan", "7"); gv.InstanceTableCell("ID编号", "rowspan", "2"); gv.InstanceTableCell("姓名", "rowspan", "2"); gv.InstanceTableCell("性别", "rowspan", "2"); gv.InstanceTableCell("年龄", "rowspan", "2"); gv.InstanceTableCell("成绩", "colspan", "3"); gv.InstanceTableCell("语文"); gv.InstanceTableCell("数学"); gv.InstanceTableCell("英语"); } } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 输入关键字,在本站1000多万海量源码库中尽情搜索: