How To add value to datagridview cell in runtime

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kisho
    New Member
    • Dec 2011
    • 4

    How To add value to datagridview cell in runtime

    Hi there
    this is my scenario
    i have created one dataGridView control in my form. It already bounded with Customers table in database.
    Please follow the picture that i have uploaded;
    the pino column should contain Invoice NO textbox's text
    for every new row until user click Generate Invoice button.
    iam using dataGridView control for inserting the values to database customers
    so how do i add value for every pino field in run time
    any help regarding to this will be appreciated
    Attached Files
  • adriancs
    New Member
    • Apr 2011
    • 122

    #2
    Code:
    int n = dataGridView1.Rows.Add();
    dataGridView1.Rows[n].Cells[0].Value = "A001-001";
    dataGridView1.Rows[n].Cells[1].Value = "This is the first Invoice";
    dataGridView1.Rows[n].Cells[2].Value = "Something about the Invoice";
    dataGridView1.Rows[n].Cells[3].Value = 55;
    dataGridView1.Rows[n].Cells[4].Value = 98.30;
    dataGridView1.Rows[n].Cells[5].Value = (decimal)dataGridView1.Rows[n].Cells[3].Value * (decimal)dataGridView1.Rows[n].Cells[4].Value;

    Comment

    • kisho
      New Member
      • Dec 2011
      • 4

      #3
      Thank you so much adriancs......
      keep up the good work

      Comment

      Working...