110,536
社区成员
发帖
与我相关
我的任务
分享
<Label Height="24" Margin="0,250,0,0" Name="label10" VerticalAlignment="Top" HorizontalAlignment="Left" Width="90">联系电话:</Label>
<TextBox Text="{Binding Telephone}" Height="23" Margin="0,252,8,0" Name="textBox10" VerticalAlignment="Top" Grid.Column="1" />
<Label Height="24" Margin="3,278,0,0" Name="label11" VerticalAlignment="Top" HorizontalAlignment="Left" Width="90">检查结果:</Label>
<ComboBox Height="19" HorizontalAlignment="Left" Margin="0,312,0,0" Name="comboBox2" VerticalAlignment="Top" Width="111" Grid.Column="1" >
<ComboBoxItem Content="待查" />
<ComboBoxItem Content="阴性" />
<ComboBoxItem Content="阳性" />
</ComboBox>
/// <summary>
/// 存储相应的信息
/// </summary>
public class Result
{
/// <summary>
/// 数据库记录ID
/// </summary>
public int ID { get; set; }
/// <summary>
/// HIV
/// </summary>
public string Hiv { get; set; }
}
string str = "select ID,Hiv from table"; //填充result
string hiv = string.Empty; //当前记录的hiv
//查询到结果后
ObservableCollection<Result> result = new ObservableCollection<Result>();
comboBox2.DisplayMemberPath = "Hiv";
comboBox2.SelectedValuePath = "Hiv";
comboBox2.ItemsSource = result;
comboBox2.SelectedItem = result.FirstOrDefault(c => c.Hiv == hiv);