LookUpEdit、RepositoryItemLookUpEdit、RepositoryItemGridLookUpEdit

LookUpEdit

  • 类图:DevExpress.XtraEditors.LookUpEdit

    • LookUpEdit→ LookUpEditBasePopupBaseAutoSearchEdit → PopupBaseEdit → ButtonEdit → TextEdit → BaseEdit → BaseControl → ControlBase → Control
  • Text、EditValue、DataSource DisplayMemberValueMember 、ImmediatePopup、AutoSearchColumnIndex、SearchMode

  • 获取值

    string id = this.lookUpEdit1.EditValue.ToString(); //是lookUpEdit.Properties.ValueMember的值
     
    string name = this.lookUpEdit1.Text.Trim(); //是lookUpEdit.Properties.DisplayMember的值
     
    
  • SearchMode:

    • OnlyInPopup:配合ImmediatePopup=true使用,并根据输入的字符从头部开始匹配AutoSearchColumnIndex属性指定栏位字段的值,默认为第一栏位0

    • AutoComplete,配合ImmediatePopup=true使用,并在输入框自动完成你想要输入的数据,同时下拉窗体自动匹配最佳记录,这个值匹配DisplayMember对应的字段。特点:能在输入框显示匹配的数据,并且下拉窗体显示匹配的记录

    • AutoFiler : 配合ImmediatePopup=true使用,并在输入框自动完成你想要输入的数据,同时下拉窗体自动过滤不匹配的记录。这个值匹配DisplayMember对应的字段。特点:能过滤掉不想要的数据,自动过滤掉不匹配的数据

      // lookUpEdit1
      lookUpEdit1.Properties.DisplayMember = "CLASS_NAME"; // 可以不指定,但是影响Text
      lookUpEdit1.Properties.ValueMember = "CLASS_CODE"; // 可以不指定,但是影响 EditValue
      lookUpEdit1.Properties.DataSource = dt;
      // 修改此项可以设置为是否允许用户编辑DisableTextEditor(不允许,默认),
      // Standard(允许编辑) ,但是必须是下拉框内数据,否则清空编辑器
      lookUpEdit1.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;
      
      

RepositoryItemLookUpEdit

  • 下拉框

  • public class ComboxList
    {
        public string ItemCode { get; set; }
        public string ItemName { get; set; }
    
        public ComboxList(string itemCode, string itemName)
        {
            ItemCode = itemCode;
            ItemName = itemName;
        }
    }
    
    BindingList<ComboxList> blSummaryType = new BindingList<ComboxList>() {
        new ComboxList("0","Sum"),
        new ComboxList("1","Min"),
        new ComboxList("2","Max"),
        new ComboxList("3","Count"),
        new ComboxList("4","Average"),
        new ComboxList("5","Custom"),
        new ComboxList("6","None")
    };
    
    RepositoryItemLookUpEdit riluSummaryType = new RepositoryItemLookUpEdit()
    {
        DataSource = blSummaryType,
        DisplayMember = "ItemName",
        ValueMember = "ItemCode",
        NullText = ""
    };
    riluSummaryType.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] {
        new DevExpress.XtraEditors.Controls.LookUpColumnInfo("ItemCode","代码",30),
        new DevExpress.XtraEditors.Controls.LookUpColumnInfo("ItemName","名称",70),
    });
    gridView2.Columns["SummaryType"].ColumnEdit = riluSummaryType;
    

RepositoryItemGridLookUpEdit

  • 和RepositoryItemLookUpEdit不同之处在于他具有Grid的属性,可以多列,可以点击表头的小漏斗过滤数据

  • 使用方法

RepositoryItemGridLookUpEdit riluFormatType = new RepositoryItemGridLookUpEdit()
{
    DataSource = blFormatType,
    DisplayMember = "ItemName",
    ValueMember = "ItemCode",
    NullText = ""
};
GridColumn riglupgcId = riluFormatType.View.Columns.AddField("ItemCode");
riglupgcId.Caption = "编号";
riglupgcId.VisibleIndex = 0;
riglupgcId.Width = 30;
GridColumn riglupgcName = riluFormatType.View.Columns.AddField("ItemName");
riglupgcName.Caption = "名称";
riglupgcName.VisibleIndex = 1;
riglupgcName.Width = 70;
riluFormatType.View.Columns.Add(riglupgcId);
riluFormatType.View.Columns.Add(riglupgcName);
gridView2.Columns["FormatType"].ColumnEdit = riluFormatType;

posted @ 2022-08-20 16:55  his365  阅读(1339)  评论(0编辑  收藏  举报