private void GeraHistorico() { try { ViewDispensacaoPorUsuarioTableAdapter dispensacao = new ViewDispensacaoPorUsuarioTableAdapter(); dtgHistorico.DataSource = dispensacao.RetornaDataTable(int.Parse(txIDUsuario.Text)); cbDataHistorico.Items.Clear(); string data = ((DateTime)dtgHistorico[0, 0].Value).ToShortDateString(); cbDataHistorico.Items.Add(data); for (int i = 1; i < dtgHistorico.Rows.Count; i++) { data = ((DateTime)dtgHistorico[0, i].Value).ToShortDateString(); int count = 1; for (int j = 0; j < cbDataHistorico.Items.Count; j++) { if (data.Equals(cbDataHistorico.Items[j].ToString())) count++; } if (count < 2) cbDataHistorico.Items.Add(data); } } catch (Exception err) { MessageBox.Show("Não há histórico para o paciente. " + err.Message); } }