0

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

2
Contributors
1
Reply
14
Views
3 Years
Discussion Span
Last Post by Daemon_CC
0

you can try following syntax for inserting data values
dataGridView1.Rows[rowIndex].Cells[columnIndex].Value = value;

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.