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

widy guiPosted Jun 9, 2014, 10:24 PM
I have a table of datagridview,the thing is I want to put a lot of data into my datagridview. So I write the code(below). when i run it,it's okay. everything is fine. when I type data into a textbox and I hit a save button,the data shows into the first row of my datagridview. It's still fine.
Here's the problem,when I type a different data into a textbox and I hit a save button,the data just cover the previous data(it's mean it shows into the first row ),I just have no idea how to put the data into my second row,so my first data still in the first row...
Oh Yeah.. Thanks to responde anyway..
Here is my latest code..
int j = 0, k = 0, l = 1;
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");
}
VulpesPosted Jun 9, 2014, 7:31 PM
I couldn't understand what it was from your description.