SqlConnection conn = new SqlConnection();
conn.ConnectionString = "..";
conn.Open();
Acasa main = (Acasa)Application.OpenForms["Acasa"];
DataGridView dgv = main.categdaGridView;
int i = dgv.CurrentRow.Index;
textBox1.Text = dgv.Rows[i].Cells[1].Value.ToString();
textBox3.Text = dgv.Rows[i].Cells[3].Value.ToString();
comboBox1.SelectedItem = dgv.Rows[i].Cells[2].Value.ToString();
conn.Close();
but the comboBox doesn't select nothing :| if i do comboBox1.SelectedItem="discount" it works, and i checked dgv.Rows[i].Cells[2].Value.ToString(); has the same value(discount). Does anybody know what could cause it? Thank u very much.
but the comboBox doesn't select nothing :| if i do comboBox1.SelectedItem="discount" it works, and i checked dgv.Rows[i].Cells[2].Value.ToString(); has the same value(discount). Does anybody know what could cause it? Thank u very much.

Dillon GoedaPosted Apr 6, 2013, 10:14 AM
Private void dgv_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
int i= dgv.CurrentRow.Index;
comboBox1.SelectedItem = dgv.Rows[I].Cells[1].Value.ToString();
}
Or the same code in the button1_Click(...)
If I use the first code, it change everytime click on a new row
VulpesPosted Apr 6, 2013, 10:10 AM
comboBox1.SelectedText = "adaos";
select adaos?
If it doesn't, then possibly the value in the comboBox has some whitespace at the end?
Violeta PopaPosted Apr 6, 2013, 9:59 AM
Dillon GoedaPosted Apr 6, 2013, 9:34 AM
Violeta PopaPosted Apr 6, 2013, 9:15 AM
For exemple:
B1 discount 10
B2 adaos 5
B3 discount 10
if i select the first row, the cb shows discount, but if then i select the second row..doesn't show adaos, it's still discount :(
VulpesPosted Apr 6, 2013, 6:32 AM
Try setting the comboBox1.SelectedText property instead of the SelectedItem property.
Dillon GoedaPosted Apr 6, 2013, 4:10 AM