List of Exercises

Programmatically Add Data to DataGridView in C#

	
namespace programmatically_add_data_to_dataGV
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
    }

    private void fill_Click(object sender, EventArgs e)
    {
      for (int i = 0; i < 5; i++)
      {
        DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[i].Clone();
        row.Cells[0].Value = "ID_" + (i + 1).ToString();
        bool c = false;
        if (i % 2 == 0)
          c = true;
        row.Cells[1].Value = c;
        for (int it = 0; it < 3; it++)
        {
          ((DataGridViewComboBoxCell)row.Cells[2]).Items.Add((it * 10 + i).ToString());
        }
        dataGridView1.Rows.Add(row);
      }
    }


  }
}

	


Download the project of Visual Studio 2013 in DropBox Download


Programmatically Add Data to DataGridView in C# | On Button Click | DataGridViewComboBoxColumn


Video Thumbnail