widy gui

widy gui

  • NA
  • 8
  • 2.6k

How to input data in multi row into datagridview

Jun 9 2014 11:56 AM
Hi Everyone.
 
I got a problem when I want to input data into my second row. whenever i try to insert data,the data always appeared in the row.
here's my code...
private void btnTambahStock_Click(object sender, EventArgs e)
{
int i = 0, j = 0, k = 0, l = 1;
if (dataGridView1[i, j].Value != "")
{
j++;
}
if (txtKodeBukuStock.Text != "" && txtJudulBukuStock.Text != "" && txtPengarangStock.Text != ""
&& txtPenerbitStock.Text != "" && txtTahunTerbitStock.Text != "" && txtJlhBukuStock.Text != "")
{
dataGridView1[k, j ].Value = txtKodeBukuStock.Text;
dataGridView1[k = k + l, j ].Value = txtJudulBukuStock.Text;
dataGridView1[k = k + l, j ].Value = txtPengarangStock.Text;
dataGridView1[k = k + l, j ].Value = txtPenerbitStock.Text;
dataGridView1[k = k + l, j ].Value = txtTahunTerbitStock.Text;
dataGridView1[k = k + l, j ].Value = txtJlhBukuStock.Text;
}
else
{
//menampilkan messageBox
MessageBox.Show("Isi textBox terlebih dahulu", "Error");
}
}
 
 
I would like to get any idea about this.. thanks 

Answers (2)