using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using DevExpress.XtraEditors; namespace WindowsFormsApplication7 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { lookUpEdit1.Properties.DisplayMember = "ID"; lookUpEdit1.Properties.ValueMember = "Names"; lookUpEdit1.Properties.DataSource = InitData(); lookUpEdit1.Properties.NullText = "请输入"; lookUpEdit1.Properties.PopulateColumns(); lookUpEdit1.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; // lookUpEdit1.Properties.ImmediatePopup = true; lookUpEdit1.ItemIndex = -1; lookUpEdit1.Properties.Columns[0].Caption = "ID 号码"; lookUpEdit1.Properties.Columns[1].Caption = "姓名"; lookUpEdit1.Properties.Columns[1].Width = 120; lookUpEdit1.Properties.Columns[2].Width = 300; lookUpEdit1.Properties.Columns[2].Alignment = DevExpress.Utils.HorzAlignment.Center; // lookUpEdit1.Properties.Columns[2]. //控制选择项的总宽度 lookUpEdit1.Properties.PopupWidth = 500; } private List<per> InitData() { List<per> list = new List<per>(); list.AddRange(new per[] { new per("12", "zwj1"), new per("123", "zwj33"), new per("12345", "z4wj3"), new per("123456", "zwj3123") }); return list; } private void lookUpEdit1_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e) { } private void lookUpEdit1_EditValueChanged(object sender, EventArgs e) { this.Text = (sender as LookUpEdit).Text; this.Text += "*******" + lookUpEdit1.Text + "--" + lookUpEdit1.EditValue; } } public class per { public per(string id, string names) { this.ID = id; this.Names = names; } public string ID { get; set; } public string Names { get; set; } } }
时间: 2024-12-24 04:22:13