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