int index= this.dataGridView1.rows.Add(); 先执行这行代码,然后访问任意行,不崩溃,

赋值不存在的行,只是不显示,或者无值。

什么原理呢?

一些其他

private void Form1_Load(object sender, EventArgs e)
{
add_9();

dataGridView1.Rows[0].Cells[3].Value = "1行3列";
dataGridView1.Rows[7].Cells[3].Value = "7行4列";
dataGridView1.Rows[8].Cells[2].Value = "8行4列";
dataGridView1.Rows[9].Cells[3].Value = "8行5列";
dataGridView1.Rows[7].Cells[1].Value = "7行4列";
dataGridView1.Rows[9].Cells[2].Value = "9行3列";
dataGridView1.Rows[6].Cells[3].Value = "6行4列";
}

void add_9()
{
for (int i = 0; i < 9; i++)
{

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

}

}

DataGridView 访问任意行不崩溃的更多相关文章

  1. C#控制定位Word光标移动到任意行或者最后一行,取得光标位置等操作

    C#控制定位Word光标移动到任意行或者最后一行,取得光标位置等操作 http://blog.csdn.net/jglie/article/details/7394256 十一.上下左右移动光标位 p ...

  2. [No000018E]Vim快速跳转任意行、任意列以及高亮显示当前行、当前列方法-Vim使用技巧(3)

    vim提供了丰富的快速跳转任意行.任意列的方法,方便高效地移动光标,定位文件位置. 一.Vim行跳转 使用vim查看文件时,使用以下命令可以快速跳转文件首.尾行,方便对整个文件有个全局把握. 1.1 ...

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

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

  4. c# datagridview 设置某行不可见解决办法

    [前提]datagridview与数据库绑定,需要单独设置某行或者某个单元格不可见. [问题分析]直接用this.dataGridCiew1.Rows[0].Visible = false;不可行,会 ...

  5. datagridview 如何禁止行被选中

    如题,如何规定特定的行,光标不能定位,也不能被选中,就好想Button中的Enable属性那样,变灰,而且点击也没有反应那种,这样的效果,如何实现. datagridview [解决办法]dataGr ...

  6. winform DataGridView添加合计行

    使用方法 /* DataTable dt= DBUtility.DB.FromSql(sql).ToDataTable(); DataGridViewAddSumRow sumRow = new Da ...

  7. [WCF] - 访问任意方法耗时长问题之解决

    问题 访问 WCF 任意方法耗时都很长(15s+) 原因 当执行语句 log4net.Config.XmlConfigurator.Configure(); 时需要连接到 log4net 对应的数据库 ...

  8. Tomcat访问任意磁盘的图片资源

    项目中用户上传的大量图片存放在项目底下带来诸多不便.每次部署项目都需要拷贝出来,防止覆盖掉以前的 图片.容易丢失,前功尽弃.甚至造成经济损失.不可估量. 如何配置tomcat访问图片路径呢?首页你代码 ...

  9. 問題排查:DataGridView 資料行下拉選單,資料繫結階段顯示 DataGridViewComboBoxCell 值無效

    可能原因: 1.下拉選單的選項資料繫結晚於 DataGridView 的資料繫結 2.下拉選單的 DataPropertyName 屬性,比 DisplayMember.ValueMember 早賦值 ...

随机推荐

  1. EasyPermissions的流程

    在app的build.gradle文件的dependencies中,添加依赖: implementation 'pub.devrel:easypermissions:1.3.0' import and ...

  2. 【ORACLE】解锁scott帐号

    sqlplus / as sysdba;SQL> alter user scott account unlock;SQL> conn scott/grace

  3. 安装Oracle Database 11g 找不到文件“WFMLRSVCApp.ear” .

    在64位Windows 7 系统下安装Oracle Database 11g 的过程中,出现提示:“未找到文件D:\app\Administrator\product\11.2.0\dbhome_1\ ...

  4. thinkcmf 5关闭后台验证码

    控制器修改 D:\cmf\thinkcmf\app\admin\controller\PublicController.php 注释 /* $captcha = $this->request-& ...

  5. react proxy 报错

    react项目中,package.json中proxy的配置如下 "proxy": { "/api/rjwl": { "target": & ...

  6. vue2 在mounted函数无法获取prop中的变量的解决方法

    props: { example: { type: Object, default() { }, }, }, watch: { example: function(newVal,oldVal){ // ...

  7. Javascript中只能在 HTML 输出流中使用 document.write,在文档已加载后使用它(比如在函数中),会覆盖整个文档。

    意思就是说,初次加载时如果没有加载document.write,那么再次加载的时候回覆盖掉原来的内容,只显示新加载的内容. <!DOCTYPE html> <html> < ...

  8. WebH

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net ...

  9. 第二周作业-web后台应用开发与xml

    web后台: 网站前台和网站后台通常是相对于动态网站而言,即网站建设是基于数据库开发 的网站.基于带数据库开发的网站,一般分网站前台和网站后台.网站前台是面向网站访问用户的,通俗的说也就是给访问网站的 ...

  10. LeetCode 1013 Partition Array Into Three Parts With Equal Sum 解题报告

    题目要求 Given an array A of integers, return true if and only if we can partition the array into three  ...