Common.Public comm = new Common.Public();
this.Users_User_Add_cmbDomian.DataSource = comm.GetAllDomian();
this.Users_User_Add_cmbDomian.DisplayMember = "Domain";
this.Users_User_Add_cmbDomian.ValueMember = "Domain";
this.Users_User_Add_cmbDomian.SelectedIndex = 0;
private void Users_User_Add_cmbDomian_SelectedIndexChanged(object sender, EventArgs e)
{
this.label12.Text = this.Users_User_Add_cmbDomian.Text;
}
得到的结果是 Systenm.Data.DataRowView,只有去更改combox的下拉项时,才能得到正确的结果。另外,combox的DropDownStyle设置的值为DropDownList(此处不可更改)。求:除了重写combox控件以外的解决办法。
试试这个。。
这个和this.Users_User_Add_cmbDomian.Text的值是一样的,结果是System.Data.DataRowView
this.combox.SelectedValue 这个是行,我目前用的就是这样的方法,可是那时因为我的value和text值一样,如果不一样呢?
this.Users_User_Add_cmbDomian.SelectedIndex = 0;