C# dataGridView1 添加数据 和清空数据
#region MyRegion DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn col3 = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn col4 = new DataGridViewTextBoxColumn(); DataGridViewImageColumn col5 = new DataGridViewImageColumn(); DataGridViewTextBoxCell celltext = new DataGridViewTextBoxCell(); DataGridViewImageCell cellimage = new DataGridViewImageCell(); col.CellTemplate = col1.CellTemplate = col2.CellTemplate = col3.CellTemplate = col4.CellTemplate = celltext; col5.CellTemplate = cellimage; col.HeaderText = "名称"; col1.HeaderText = "分类"; col2.HeaderText = "数量"; col3.HeaderText = "价格"; col4.HeaderText = "销售时间"; col5.HeaderText = "图片"; dataGridView1.Columns.Add(col); dataGridView1.Columns.Add(col1); dataGridView1.Columns.Add(col2); dataGridView1.Columns.Add(col3); dataGridView1.Columns.Add(col4); dataGridView1.Columns.Add(col5);
//--
DataGridViewRow row = new DataGridViewRow(); int index = dataGridView1.Rows.Add(row); dataGridView1.Rows[index].Cells[].Value = ""; dataGridView1.Rows[index].Cells[].Value = ""; dataGridView1.Rows[index].Cells[].Value = ""; dataGridView1.Rows[index].Cells[].Value = ""; dataGridView1.Rows[index].Cells[].Value = ""; // dataGridView1.Rows[index].Cells[5].Value = "";// Image.FromFile(); #endregion
this.dataGridView1.Columns.Add("0","001");//添加列
this.dataGridView1.Columns.Add("0", "002");
this.dataGridView1.Columns.Add("0", "003");
this.dataGridView1.Rows.Add("第一个字段值", "第二个字段值", "第三个字段值");
DataTable dt = (DataTable)dataGridView1.DataSource;
//dt.Rows.Count
//dt.Columns.Count
//if (dt != null&&dt.Rows.Count > 0 )
//{
// dt.Columns.Clear();
// dt.Rows.Clear();
// dataGridView1.DataSource = dt;
//}
dataGridView1.Columns.Clear();
dataGridView1.Rows.Clear();
C# dataGridView1 添加数据 和清空数据的更多相关文章
- C# DataGridView控件绑定数据后清空数据
//1.this.dataGridView1.DataSource = null;//会将DataGridView的列也删掉 //2.this.dataGridView1.Columns.Clear( ...
- C# DataGridView控件清空数据完美解决方法
C# DataGridView控件绑定数据后清空数据在清除DataGridview的数据时: 1.DataSource为NULL(DataGridView.DataSource= null;)这样会将 ...
- 转:C# DataGridView控件清空数据出错解决方法
C# DataGridView控件绑定数据后清空数据在清除DataGridview的数据时: 1.DataSource为NULL(DataGridView.DataSource= null;)这样会将 ...
- javascript之JSON小案例,实现添加数据与清楚数据
对json应用给出一个小案例,加深一些理解: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" & ...
- Eclipse中java向数据库中添加数据,更新数据,删除数据
前面详细写过如何连接数据库的具体操作,下面介绍向数据库中添加数据. 注意事项:如果参考下面代码,需要 改包名,数据库名,数据库账号,密码,和数据表(数据表里面的信息) package com.ning ...
- Jmeter—4 添加断言 判断响应数据是否符合预期
发出请求之后,通过添加断言可以判断响应数据是否是我们的预期结果. 1 在Jmeter中发送一个登录的http请求(参数故意输入错误).结果肯定是登陆失败啦. 但结果树中http请求的图标显示‘绿色’表 ...
- Oracle session inactive状态临时表数据未清空问题
问题描述:Oracle数据库,java代码使用某数据库实例,获取connection并在使用结束关闭,而session未销毁,而是状态变为inactive从而导致临时表数据未清空. Oracle临时表 ...
- 删除数据表和清空数据表的内容(保存表结构)的SHELL脚本
A,删除指定数据库的所有数据表 #!/bin/bash # 删除mysql中所有表 # 示例: # Usage: ./script user password dbnane # Usage: ./sc ...
- 金蝶KIS专业版替换SXS.dll 遭后门清空数据被修改为【恢复数据联系QQ 735330197,2251434429】解决方法 修复工具。
金蝶KIS专业版 替换SXS.dll 遭后门清空数据(凭证被改为:恢复数据联系QQ 735330197,2251434429)恢复解决方法. [客户名称]:山东青岛福隆发纺织品有限公司 [软件名称]: ...
随机推荐
- (22)Spring Boot 拦截器HandlerInterceptor【从零开始学Spring Boot】
上一篇对过滤器的定义做了说明,也比较简单.过滤器属于Servlet范畴的API,与Spring 没什么关系. Web开发中,我们除了使用 Filter 来过滤请web求外,还可以使用Sprin ...
- dubbo-源码阅读之dubboSpi实现原理
dubboSPI实现思想跟javaspi的思想差不多javaspi是ServiceLoad 而dubbo自己写的是ExtensionLoader SPI接口定义 @Documented @Retent ...
- 转载 - kmp next函数 kmp的周期问题,深入了解kmp中next的原理
出处:http://www.cnblogs.com/wuyiqi/archive/2012/01/06/2314078.html kmp next函数 kmp的周期问题,深入了解kmp中next的原理 ...
- btrfs
https://docs.docker.com/storage/storagedriver/btrfs-driver/ $ sudo cat /proc/filesystems | grep btrf ...
- 1013MySQL监控利器-Innotop
转自 http://www.cnblogs.com/ivictor/p/5101506.html 安装过程中 可以使用 YUM INSTALL INNOTOP进行直接安装 Innotop是一款十分强大 ...
- uva 10479(找规律+递归)
题意:有一个初始序列第一个数字是0. 规律是把前一次推出来的每个数字x.先接x个0,然后接x+1. 0 –> 1 –> 02 –> 1003 –> 02110004 那么这个序 ...
- javascript学习笔记(一)-廖雪峰教程
一. 基础 1.for in,for of和forEach 遍历的是对象的属性,因为数组也是对象,其内部的元素的索引就是其属性值.用该方式遍历数组就是获取了数组中的每一个元素的索引值(从0開始). 而 ...
- Lua 与C/C++ 交互系列:注冊枚举enum到Lua Code中
在Lua Code中注冊C/C++的枚举很easy,就像注冊全局变量一样.我们使用枚举名称作为命名空间,来避免注冊的枚举发生冲突.注冊的枚举存储在全局环境(线程环境)中. 当在Lua Code中訪问枚 ...
- 《Head First 设计模式》学习笔记——复合模式
模型-视图-控制器(MVC模式)是一种很经典的软件架构模式.在UI框架和UI设计思路中扮演着很重要的角色.从设计模式的角度来看,MVC模式是一种复合模式.它将多个设计模式在一种解决方式中结合起来,用来 ...
- GammaRay 是一个允许你查看 Qt 应用程序甚至在某种程度上修改它的独特应用,可谓是 Debugger 的良好补充
GammaRay is a tool to poke around in a Qt-application and also to manipulate the application to some ...