#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. js中call、apply、bind的区别

    var Person = { name : 'alice', say : function(txt1,txt2) { console.info(txt1+txt2); console.info(thi ...

  2. 域名IP绑定

    该文为阿里云域名举例 首先具备3个前提: 买服务器并搭建环境:阿里云官网购买阿里云的服务器(我购买的是window系统,ECS服务器). 在自己的云服务器上布置上jdk,配置环境变量:安装上tomca ...

  3. 工厂模式的python实现

    #1.什么是工厂模式 #2.工厂模式的分类 ''' 1. 简单工厂模式 2. 工厂方法模式 3. 抽象工厂方法模式 ''' #3.简单工厂模式的python实现 from abc import ABC ...

  4. 【hihocoder 1295】Eular质数筛法

    [题目链接]:http://hihocoder.com/problemset/problem/1295 [题意] [题解] 可以在O(N)的复杂度内求出1..N里面的所有素数; 当然受空间限制,N可能 ...

  5. 【ACM】poj_2092_Grandpa is Famous_201308021920

    Grandpa is FamousTime Limit: 2000MS  Memory Limit: 30000K Total Submissions: 7256  Accepted: 3670 De ...

  6. C#--Task知识点

    5天玩转C#并行和多线程编程 TASK使用总结 Task是什么,字面意思是任务 表示一个异步操作.它是异步操作的首选方式.Task是FRAMEWORK4中的新特性,封装了以前的Thread,并管理Th ...

  7. i386和x86-64区别通俗易懂版本(转)

    x86架构首度出现在1978年推出的Intel 8086中央处理器,它是从Intel 8008处理器中发展而来的,而8008则是发展自Intel 4004的.Intel之后又推出了包括80186.80 ...

  8. Arcengine设置坐标系

    转自原文 Arcengine设置坐标系 ArcGIS Engine提供了一系列对象供开发者管理GIS系统的坐标系统. 对大部分开发者而言了解ProjectedCoordinateSystem, Geo ...

  9. WIN7通过批处理开启/禁用无线网卡

    哥比較懒,直接上步骤: 1.看自己的电脑是否有devcon.exe 这个软件,能够直接在WINDOWS文件夹的SYSTEM32文件夹下面搜索.也能够通过命令行RUN-----------CMD---- ...

  10. Python3 pymysql连接MySQL数据库

    #!/usr/bin/python # -*- coding:utf8 -*- import pymysql #取得数据库连接对象 conn = pymysql.connect(host='127.0 ...