-
大小: 0.12M文件类型: .zip金币: 1下载: 0 次发布日期: 2020-12-25
- 语言: C#
- 标签: C# DataGridView
资源简介
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; namespace DataGridViewSample { public partial class Form1 : Form { public static List<Test> Tests = new List<Test>(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.dataGridView1.DataSource = Tests; } private void button1_Click(object sender, EventArgs e) { frmAdd form = new frmAdd(null); if (form.ShowDialog() == DialogResult.OK) { this.dataGridView1.DataSource = null; this.dataGridView1.DataSource = Tests; } } private void button2_Click(object sender, EventArgs e) { if (this.dataGridView1.SelectedRows != null) { frmAdd form = new frmAdd(new Test( Convert.ToInt32(this.dataGridView1.SelectedRows[0].Cells[0].Value), Convert.ToDecimal(this.dataGridView1.SelectedRows[0].Cells[1].Value), Convert.ToDateTime(this.dataGridView1.SelectedRows[0].Cells[2].Value), this.dataGridView1.SelectedRows[0].Cells[3].Value.ToString())); if (form.ShowDialog() == DialogResult.OK) { this.dataGridView1.DataSource = null; this.dataGridView1.DataSource = Tests; } } } private void button3_Click(object sender, EventArgs e) { //使用前面示例中的代码,用DataGridView或者List<Test>来做导出都是可以的 } } public class Test { public Test(int id, decimal voltage, DateTime record, string remark) { ID = id; Voltage = voltage; Record = record; Remark = remark; } public int ID { get; set; } public decimal Voltage { get; set; } public DateTime Record { get; set; } public string Remark { get; set; } } }
代码片段和文件信息
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;
namespace DataGridViewSample
{
public partial class Form1 : Form
{
public static List Tests = new List();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender EventArgs e)
{
this.dataGridView1.DataSource = Tests;
}
private void button1_Click(object sender EventArgs e)
{
frmAdd form = new frmAdd(null);
if (form.ShowDialog() == DialogResult.OK)
{
this.dataGridView1.DataSource = null;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 896 2015-05-26 15:43 DataGridViewSample\DataGridViewSample.sln
文件 20992 2015-05-26 15:43 DataGridViewSample\DataGridViewSample.suo
文件 46080 2015-06-11 09:35 DataGridViewSample\DataGridViewSample.v12.suo
目录 0 2015-05-27 07:39 DataGridViewSample\DataGridViewSample\
目录 0 2015-05-26 15:43 DataGridViewSample\DataGridViewSample\bin\
目录 0 2015-05-26 15:43 DataGridViewSample\DataGridViewSample\bin\Debug\
文件 14848 2015-05-27 07:39 DataGridViewSample\DataGridViewSample\bin\Debug\DataGridViewSample.exe
文件 40448 2015-05-27 07:39 DataGridViewSample\DataGridViewSample\bin\Debug\DataGridViewSample.pdb
文件 23168 2015-06-11 09:34 DataGridViewSample\DataGridViewSample\bin\Debug\DataGridViewSample.vshost.exe
文件 490 2013-06-18 20:28 DataGridViewSample\DataGridViewSample\bin\Debug\DataGridViewSample.vshost.exe.manifest
文件 4004 2015-05-26 15:43 DataGridViewSample\DataGridViewSample\DataGridViewSample.csproj
文件 2332 2015-05-27 07:39 DataGridViewSample\DataGridViewSample\Form1.cs
文件 5403 2015-05-26 15:43 DataGridViewSample\DataGridViewSample\Form1.Designer.cs
文件 5817 2015-05-26 15:43 DataGridViewSample\DataGridViewSample\Form1.resx
文件 1698 2015-05-26 15:43 DataGridViewSample\DataGridViewSample\frmAdd.cs
文件 7009 2015-05-26 15:43 DataGridViewSample\DataGridViewSample\frmAdd.Designer.cs
文件 5817 2015-05-26 15:43 DataGridViewSample\DataGridViewSample\frmAdd.resx
目录 0 2015-05-26 15:43 DataGridViewSample\DataGridViewSample\obj\
目录 0 2015-05-26 15:43 DataGridViewSample\DataGridViewSample\obj\x86\
目录 0 2015-05-27 07:39 DataGridViewSample\DataGridViewSample\obj\x86\Debug\
文件 2108 2015-06-11 09:34 DataGridViewSample\DataGridViewSample\obj\x86\Debug\DataGridViewSample.csproj.FileListAbsolute.txt
文件 1036 2015-05-26 15:44 DataGridViewSample\DataGridViewSample\obj\x86\Debug\DataGridViewSample.csproj.GenerateResource.Cache
文件 9180 2015-05-26 15:44 DataGridViewSample\DataGridViewSample\obj\x86\Debug\DataGridViewSample.csprojResolveAssemblyReference.cache
文件 14848 2015-05-27 07:39 DataGridViewSample\DataGridViewSample\obj\x86\Debug\DataGridViewSample.exe
文件 180 2015-05-26 15:43 DataGridViewSample\DataGridViewSample\obj\x86\Debug\DataGridViewSample.Form1.resources
文件 180 2015-05-26 15:43 DataGridViewSample\DataGridViewSample\obj\x86\Debug\DataGridViewSample.frmAdd.resources
文件 40448 2015-05-27 07:39 DataGridViewSample\DataGridViewSample\obj\x86\Debug\DataGridViewSample.pdb
文件 180 2015-05-26 15:44 DataGridViewSample\DataGridViewSample\obj\x86\Debug\DataGridViewSample.Properties.Resources.resources
文件 2873 2015-05-26 15:44 DataGridViewSample\DataGridViewSample\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7122 2015-06-11 09:32 DataGridViewSample\DataGridViewSample\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
目录 0 2014-05-02 12:16 DataGridViewSample\DataGridViewSample\obj\x86\Debug\TempPE\
............此处省略8个文件信息
相关资源
- C#联通网络宽带测试 拨号
- C#百度指数抓取方法(2012年版本已失
- C# 隐藏某个磁盘分区
- C# 读取并编辑window系统的右键菜单
- C#自定义屏保(不断滚动的文字)
- C#winform打印指定区域 -控件拖动 -设置
- C#使用Hook进行改键
- 提供C#调用系统API函数弹出或收起光驱
- 通过C#自带的头文件(类)获取Windo
- C#获取电脑CPU以及内存使用率
- 利用uu云打码平台的lib实现的c#打码平
- tf-idf一种计算方法
- C# pop3 邮件接收程序
- C# 邮件群发示例 源码下载18952
- 动态抓取IPC#实现
- XXTEA算法的C#实现和JS实现,可以互相
- C# 飞行棋 游戏源码(面向对象入门)
- 基于WinPcap的C# ARP欺骗软件().rar
- C#网络应用编程 矩阵并行计算练习
- 《C#版Ftp软件源码》
-
C# 播放铃声(AxWindowsMediaPla
yer)最新 - C# 把图片显示成椭圆形状
- C# 水平交错效果显示图像
- winform 浮雕效果的图像
- c# 底片效果显示图像就像旧式相机的
- 积木效果显示图像
- C# 隐形窗体 (没有边框,没有标题栏
- browerPhotoC#网页截图(不打开网页)
- C# 模拟时钟(自绘Graphics)
- C#之WPF重绘动态正弦余弦曲线
评论
共有 条评论