2
Answers

Combobox value member problem

count nazgul

count nazgul

16y
8.6k
1
Hello to all!
I've got problem with getting values from combobox. Code below how i get data from database and populate it in combobox. The problem is that few lines below this code i need to get value member value when something is selected in this combobox. With this code VS compile successfully. But the result is not correct. I'm not sure that this code actually works correct.

comboBox2.ValueMember = Issues.Tables[0].Columns[0].ToString();

If you understand me can you help me?

  String ConnStr = settings.ConnectionString().ToString();

String SQLIssues = "SELECT issueid, projid, summary FROM issues";

SqlDataAdapter IssuesAdpt = new SqlDataAdapter(SQLIssues, ConnStr);
DataSet Issues = new DataSet();

IssuesAdpt.Fill(Issues);

foreach (DataRow Issue in Issues.Tables[0].Rows)
{
comboBox2.Items.Add(Issue[2]);
comboBox2.ValueMember = Issues.Tables[0].Columns[0].ToString();
}

Answers (2)