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)恢复解决方法. [客户名称]:山东青岛福隆发纺织品有限公司 [软件名称]: ...
随机推荐
- sql查询原理
1.单表查询:根据WHERE条件过滤表中的记录,形成中间表(这个中间表对用户是不可见的):然后根据SELECT的选择列选择相应的列进行返回最终结果. 1)简单的单表查询 SELECT 字段 FROM ...
- CentOS7 笔记 (一) .NETCore
安装系统CentOS,虚拟机好麻烦,直接在阿里云开了一个6个月免费的ECS. 熟悉Linux 基本命令 登录,exit,vi ,vim,vi保存关闭,w,ls,mkdir,df,ip addr,修改系 ...
- nexus3修改admin密码
Nexus是通过内置的orientdb数据库管理,是以需要进入到库里面修改密码. 不能像这篇博客(https://blog.csdn.net/tianya6607/article/details/53 ...
- 【[Offer收割]编程练习赛11 D】排队接水
[题目链接]:http://hihocoder.com/problemset/problem/1488 [题意] 中文题 [题解] 莫队算法+树状数组; 首先贪心地知道,应该按照时间从小到大的顺序打水 ...
- 洛谷 P2764 LibreOJ 6002 最小路径覆盖问题
题目描述 «问题描述: 给定有向图G=(V,E).设P 是G 的一个简单路(顶点不相交)的集合.如果V 中每个顶点恰好在P 的一条路上,则称P是G 的一个路径覆盖.P 中路径可以从V 的任何一个顶点开 ...
- ISAP 算法的学习
http://www.renfei.org/blog/isap.html 算法与数学 网络流-最大流问题 ISAP 算法解释 2013-08-07Renfei Song 2 条评论 内容提要 [隐藏] ...
- SCU - 4110 - PE class
先上题目: 4110: PE class Submit your solution Discuss this problem Best solutions Description ...
- javascript学习笔记(一)-廖雪峰教程
一. 基础 1.for in,for of和forEach 遍历的是对象的属性,因为数组也是对象,其内部的元素的索引就是其属性值.用该方式遍历数组就是获取了数组中的每一个元素的索引值(从0開始). 而 ...
- Tomcat报错合集
1.java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start c ...
- HTML的表单form以及form内部标签
<html> <head> <title> form表单的使用 </title> <!-- 标签名称:form 表单标签 属性:action:提交 ...