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)恢复解决方法. [客户名称]:山东青岛福隆发纺织品有限公司 [软件名称]: ...
随机推荐
- cd:切换目录
cd命令 1.命令详解 [功能说明] cd命令是“change directory”中每个单词的首字母缩写,其功能是从当前工作目录切换到指定的工作目录. [语法格式] cd [option] ...
- Git 基础教程 之 添加远程仓库
b, 本地内容推送至远程库上 git push -u origin master 实际上是把当前分支master推送到远程仓库,第一次推送时,加上-u参数, 表示Git不 ...
- SQL Server 通过备份文件初始化复制 – 听风吹雨
一.背景 MySQL在对有历史数据的数据库进行搭建复制(Master/Slave)的时候,可以通过在Master服务器备份历史数据,利用这个备份文件 在Slave进行还原:这样做的好处是可以更加快速的 ...
- 编写自己的starter项目(battcn-starter-swagger)
自定义 starter 项目,方便其他地方调用,类似 spring.datasource.url 这种,本次以自己封装的 battcn-starter-swagger 为案例 创建一个Maven工程 ...
- android 点击返回键退出程序的方法
android 点击返回键退出程序的方法 第一种: 再按一次返回键退出程序 private long exitTime = 0; @Override public boolean onKeyDown( ...
- iOS项目开发实战——使用Xcode6设计自己定义控件与图形
在iOS开发中,有很多控件都是Xcode默认提供的.使用这些控件是很方便的.可是因为某些须要.须要自己设计控件,那么应该怎么做呢?在Xcode6中提供了这种接口,同意开发人员高速开发自己定义控件,而且 ...
- 使用imgareaselect 辅助后台进行图片裁剪
由于项目其中用到图片裁剪,本来能够不用到后台进行裁剪的,可是要兼容万恶的IE浏览器,所以不得不使用后台进行裁剪. 这次使用到imgareaselect 插件获取须要裁剪区域的坐标.再由后台进行裁剪操作 ...
- spring框架spring之HibernateTemplate
转自:https://blog.csdn.net/acmman/article/details/44652207
- x+=y与x=x+y相同吗?
为了将赋值操作简便化,Java提供了很多扩展赋值运算符,例如+=.-=./=.*=等等,那么问题来了,x += 1与x = x +1两者相同吗? public class EqualsTest { @ ...
- 关于c-string类
特别鸣谢:由张老师整理(原出处未知 一.C++ 字符串 C++ 提供了以下两种类型的字符串表示形式: C 风格字符串 C++ 引入的 string 类类型 1.C 风格字符串 C 风格的字符串起源于 ...