while (dr2.Read())
{
dataGridViewEx1["Sno", dataGridViewEx1.RowCount-1].Value = sno;
dataGridViewEx1["Prod_Code", dataGridViewEx1.RowCount-1].Value = dr2["Code"].ToString();
dataGridViewEx1["Description", dataGridViewEx1.RowCount-1 ].Value = dr2["Desc"].ToString();
dataGridViewEx1["Qty", dataGridViewEx1.RowCount-1 ].Value = 0;
DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)dataGridViewEx1.Rows[dataGridViewEx1.RowCount - 1].Cells["UOM"];
cell.Value = dr2["UOM1"].ToString();
dataGridViewEx1["OnHand", dataGridViewEx1.RowCount - 1].Value = dr2["Weight"].ToString();
dataGridViewEx1["uom1", dataGridViewEx1.RowCount - 1].Value = dr2["UOM"].ToString();
dataGridViewEx1["UPrice", dataGridViewEx1.RowCount - 1].Value = dr2["Price"].ToString();
dataGridViewEx1.Rows.Add(1);
//dataGridViewEx1.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
dr2.Close();
このコードは最後の行のみを追加します。なぜ前の行を追加しないのですか..... commitedit でテストしましたが、使用しません..