#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 添加数据 和清空数据的更多相关文章

  1. C# DataGridView控件绑定数据后清空数据

    //1.this.dataGridView1.DataSource = null;//会将DataGridView的列也删掉 //2.this.dataGridView1.Columns.Clear( ...

  2. C# DataGridView控件清空数据完美解决方法

    C# DataGridView控件绑定数据后清空数据在清除DataGridview的数据时: 1.DataSource为NULL(DataGridView.DataSource= null;)这样会将 ...

  3. 转:C# DataGridView控件清空数据出错解决方法

    C# DataGridView控件绑定数据后清空数据在清除DataGridview的数据时: 1.DataSource为NULL(DataGridView.DataSource= null;)这样会将 ...

  4. javascript之JSON小案例,实现添加数据与清楚数据

    对json应用给出一个小案例,加深一些理解: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" & ...

  5. Eclipse中java向数据库中添加数据,更新数据,删除数据

    前面详细写过如何连接数据库的具体操作,下面介绍向数据库中添加数据. 注意事项:如果参考下面代码,需要 改包名,数据库名,数据库账号,密码,和数据表(数据表里面的信息) package com.ning ...

  6. Jmeter—4 添加断言 判断响应数据是否符合预期

    发出请求之后,通过添加断言可以判断响应数据是否是我们的预期结果. 1 在Jmeter中发送一个登录的http请求(参数故意输入错误).结果肯定是登陆失败啦. 但结果树中http请求的图标显示‘绿色’表 ...

  7. Oracle session inactive状态临时表数据未清空问题

    问题描述:Oracle数据库,java代码使用某数据库实例,获取connection并在使用结束关闭,而session未销毁,而是状态变为inactive从而导致临时表数据未清空. Oracle临时表 ...

  8. 删除数据表和清空数据表的内容(保存表结构)的SHELL脚本

    A,删除指定数据库的所有数据表 #!/bin/bash # 删除mysql中所有表 # 示例: # Usage: ./script user password dbnane # Usage: ./sc ...

  9. 金蝶KIS专业版替换SXS.dll 遭后门清空数据被修改为【恢复数据联系QQ 735330197,2251434429】解决方法 修复工具。

    金蝶KIS专业版 替换SXS.dll 遭后门清空数据(凭证被改为:恢复数据联系QQ 735330197,2251434429)恢复解决方法. [客户名称]:山东青岛福隆发纺织品有限公司 [软件名称]: ...

随机推荐

  1. tp5 异常处理

    === <?php/** * Created by PhpStorm. * User: 14155 * Date: 2018/11/10 * Time: 0:26 */ namespace ap ...

  2. android debug签名文件

    现象 可以运行程序,但不能启动安装成功的软件 并且run application的时候也不弹出界面. 路径: C:\Users\sunfb\.android 下替换debug.keystore 就OK

  3. ReentrantLock(排他锁)

    在多线程操作时.保证一块共享资源的原子性.第一想到的就是用synchronized关键字 在jdk5提供一个更灵活更强大的 ReentrantLock 使用reentrantLock.lock();获 ...

  4. [bzoj3123][Sdoi2013]森林_主席树_启发式合并

    森林 bzoj-3123 Sdoi-2013 题目大意:给定一片共n个点的森林,T个操作,支持:连接两个不在一棵树上的两个点:查询一棵树上路径k小值. 注释:$1\le n,T \le 8\cdot ...

  5. Spark MLlib之线性回归源代码分析

    1.理论基础 线性回归(Linear Regression)问题属于监督学习(Supervised Learning)范畴,又称分类(Classification)或归纳学习(Inductive Le ...

  6. javascript学习笔记(一)-廖雪峰教程

    一. 基础 1.for in,for of和forEach 遍历的是对象的属性,因为数组也是对象,其内部的元素的索引就是其属性值.用该方式遍历数组就是获取了数组中的每一个元素的索引值(从0開始). 而 ...

  7. 卷积神经网络(CNN)基础介绍

    本文是对卷积神经网络的基础进行介绍,主要内容包含卷积神经网络概念.卷积神经网络结构.卷积神经网络求解.卷积神经网络LeNet-5结构分析.卷积神经网络注意事项. 一.卷积神经网络概念 上世纪60年代. ...

  8. Database Design for Sexbale Forum

    Mars March 17, 2015

  9. LeetCode总结 -- 树的遍历篇

    遍历树的数据结构中最常见的操作. 能够说大部分关于树的题目都是环绕遍历进行变体来解决的. 一般来说面试中遇到树的题目是用递归来解决的, 只是假设直接考察遍历. 那么一般递归的解法就过于简单了. 面试官 ...

  10. python spark 求解最大 最小 平均

    rdd = sc.parallelizeDoubles(testData); Now we’ll calculate the mean of our dataset.   1 LOGGER.info( ...