简单介绍如何为DataGridView控件动态添加新行的两种方 法:

方法一:

int index=this.dataGridView1.Rows.Add();
this.dataGridView1.Rows[index].Cells[0].Value = "1"; 
this.dataGridView1.Rows[index].Cells[1].Value = "2"; 
this.dataGridView1.Rows[index].Cells[2].Value = "监听";

方法二:

DataGridViewRow
row = new DataGridViewRow();
DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
textboxcell.Value = "aaa";
row.Cells.Add(textboxcell);
DataGridViewComboBoxCell comboxcell = new DataGridViewComboBoxCell();
row.Cells.Add(comboxcell);
dataGridView1.Rows.Add(row);

DataGridView动态添加新行的两种方法的更多相关文章

  1. windows 7中添加新硬件的两种方法(本地回环网卡)

    最近在windows7上使用VMwareWorkstation7玩一些实验,遇到需要配置不同网络的问题. 因为在windows2003server上习惯使用要本地回环网卡了,那就想着在Windows7 ...

  2. C# DataGridView控件 动态添加新行

    DataGridView控件在实际应用中非常实用,特别需要表格显示数据时.可以静态绑定数据源,这样就自动为DataGridView控件添加相应的行.假如需要动态为DataGridView控件添加新行, ...

  3. C# DataGridView控件动态添加新行

    C# DataGridView控件动态添加新行 DataGridView控件在实际应用中非常实用,特别需要表格显示数据时.可以静态绑定数据源,这样就自动为DataGridView控件添加相应的行.假如 ...

  4. C# DataGridView添加新行的2个方法

    可以静态绑定数据源,这样就自动为DataGridView控件添加 相应的行.假如需要动态为DataGridView控件添加新行,方法有很多种,下面简单介绍如何为DataGridView控件动态添加新行 ...

  5. WebGL中添加天空盒的两种方法

    天空盒 的添加可以让模型所在的场景非常漂亮,而其原理也是非常简单的,相信看完下面代码就可以明白了. 说到天空盒的两种方法,倒不如说是两种写法,分别用了纹理加载的两个方法:loadTexture和loa ...

  6. Response.Redirect 打开新窗体的两种方法

    普通情况下,Response.Redirect 方法是在server端进行转向,因此,除非使用 Response.Write("<script>window.location=' ...

  7. Response.Redirect 打开新窗口的两种方法

    一般情况下,Response.Redirect 方法是在服务器端进行转向,因此,除非使用 Response.Write("<script>window.location='htt ...

  8. Android驱动学习-APP操作新硬件的两种方法(支持添加的驱动)

    在给Android添加新的驱动后,app要如何使用呢? 正常的使用一个设备,需要getService.但是像LED等我们自己添加的硬件驱动,Android源代码根本没有我们自己添加的服务. 第一种: ...

  9. MongoDB添加secondary节点的两种方法

    前段时间维护的一个事业群的其中一条业务线的开发找到运维,提出来了一个MongoDB的优化问题,那段时间MongoDB正在从op管理移交给db进行维护,整个部门都对MongoDB的运维经验缺乏,Mong ...

随机推荐

  1. php模拟post提交文件图片等

    <?php /** * Email net.webjoy@gmail.com * author jackluo * 2014.11.21 * */ //* function curl_post( ...

  2. Android Gradle Plugin指南(三)——依赖关系、android库和多项目配置

    原文地址:http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Dependencies-Android-Librari ...

  3. [TypeScript] Catch unsafe use of "this" in TypeScript functions

    this is probably the most tricky thing to use in JavaScript and therefore TypeScript. Fortunately th ...

  4. js进阶 9-16 如何实现多选框全选和取消

    js进阶 9-16 如何实现多选框全选和取消 一.总结 一句话总结:选择取到每一个checkbox的值,然后赋值为true或者false就好. 1.如何实现多选框全选和取消? 选择取到每一个check ...

  5. 《Erlang程序设计》学习笔记-第2章 并发编程

    http://blog.csdn.net/karl_max/article/details/3977860 1. 并发原语: (1) Pid = spawn(Fun) %% 创建一个新的并发进程,用于 ...

  6. 最新版Butterknife plugin支持butterknife7.0.1和兼容butterknife 6.1.0及下面

    JakeWharton 的butterknife帮我们有效的攻克了findViewById及各种view的监听事件泛滥的问题,极大的简化了代码,假设使用了android Studio开发的配上avas ...

  7. 【22.70%】【codeforces 591C】 Median Smoothing

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. HTML_ul无序列表

    本文来源于:http://blog.csdn.net/svitter 嵌套无序列表应用 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tra ...

  9. 【19.27%】【codeforces 618D】Hamiltonian Spanning Tree

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  10. 禁止Delphi2010检测新版本

    启动Delphi2010后,Delphi2010 总会提示下载更新包,而对于D版用户来说,这个功能可能反而带来麻烦,那么有解决办法吗?答案是肯定的.1. 打开 C:\Documents and Set ...