Đọc thật kỹ hướng dẫn cách lấy mã để lấy link tải, đặc biệt xem kỹ hướng dẫn ở bước 4, coi chừng lấy mã nhầm nhé!
Với link rút gọn dạng yeumoney.com này, nhớ xem kỹ nút lấy mã là màu ĐỎ Mô tả hình ảnh ở cuối trang, hay nút màu XANHMô tả hình ảnhở gần giữa trang, coi chừng nhầm nút

DataGridView là một điều khiển mạnh mẽ dùng để hiển thị dữ liệu.

Ví dụ ta cần hiển thị dữ liệu lên Datagridview như hình dưới, theo dòng và theo cột.

Ta đưa lên form một Datagridview có tên là Datagridview1, đưa code sau vào sự kiện form_load()

            dataGridView1.ColumnCount = 3;
            dataGridView1.Columns[0].Name = "Product ID";
            dataGridView1.Columns[1].Name = "Product Name";
            dataGridView1.Columns[2].Name = "Product Price";

            string[] row = new string[] { "1", "Product 1", "1000" };
            dataGridView1.Rows.Add(row);
            row = new string[] { "2", "Product 2", "2000" };
            dataGridView1.Rows.Add(row);
            row = new string[] { "3", "Product 3", "3000" };
            dataGridView1.Rows.Add(row);
            row = new string[] { "4", "Product 4", "4000" };
            dataGridView1.Rows.Add(row);

By alaza7

Leave a Reply

Your email address will not be published. Required fields are marked *