C#DataGridView的简单使用


首先创建一个DataGridView控件,然后创建列(包括列名的定义),

由于我不是和数据库进行连接,只是为了输出好看一点。

删除所有数据:

while (this.dataGridView1.Rows.Count != 0)
            {
                this.dataGridView1.Rows.RemoveAt(0);
            }

添加一行数据:

index = this.dataGridView1.Rows.Add();//获取新的一行

                this.dataGridView1.Rows[index].Cells[0].Value = “第一列”;
                this.dataGridView1.Rows[index].Cells[1].Value = “输出形式为字符串”;
                this.dataGridView1.Rows[index].Cells[2].Value = "第三列";
           


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM