Hello,
In my application i have a combobox populated from database:
Program.Connection.CommandText = "SELECT LastName + ', ' + FirstName + ' ' + IIF(MiddleName, MiddleName,'') AS NumeComplet, ClientId FROM Clients GROUP BY ClientId, LastName, FirstName, MiddleName ORDER BY ClientId";
DataTable Table = new DataTable();
Program.Connection.FillDataTable(Table, true);
cboNumeClient.DataSource = Table;
cboNumeClient.DisplayMember = "NumeComplet";
cboNumeClient.ValueMember = "ClientId";
cboNumeClient.Focus();
NumeClient();
ClientiAdaugati = true;
InformatiiClient();
and a selected index event:
private void cboNumeClient_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.ClientiAdaugati)
{
NumeClient();
InformatiiClient();
}
}
In the database i have customers with the same first name and last name, each one have it's own ID.
When i select i client i use the ID to populate a datagridview.
The problem is:
For example the:
client John John - ID - 2345, and
client John John - ID - 2390.
When i select the second name (id - 2390) from combobox, my datagridview fill whit according data, but when i click on a control from my windows, my combobox auto select the firs client (id 2345).
How do i resolve that?