[DevExpress]TokenEdit控件使用

用到的基础数据:

public class Product
    {
        public int Id { get; set; }
        public string Model { get; set; }
        public string Name { get; set; }
    }
   public class Entility 
   {
       private static string GetChar(int number)
       {
           string[] array = new string[] { "A","B","C","D","E","F","G","H","I"};
           string result = array[number % 9];
           return result;
       }
       private static string GetName(int number)
       {
           string[] array = 
           {
               "Unitch数据采集器","MS扫描枪","105SL","TSC","PH880","MS320便携式打印机","PA700","DSX800电脑","HP打印机"
           };
           string result = array[number % 9];
           return result;
       }

       public static List<Product> GetProductList() 
       {
           List<Product> list = new List<Product>();
           for (int i = 0; i < 200; i++)
           {
               Product product = new Product() 
               {
                   Id=100+i,Model=GetChar(i)+i.ToString()+"DLJ",Name=GetName(i)+i.ToString()
               };
               list.Add(product);
           }
           return list;
       }
       public static DataTable GetDataTable() 
       {
           DataTable dt = new DataTable();
           dt.Columns.Add("Id",typeof(System.Int32));
           dt.Columns.Add("Model", typeof(System.String));
           dt.Columns.Add("Name", typeof(System.String));
           for (int i = 0; i < 200; i++)
           {
               DataRow dr = dt.NewRow();
               dr["Id"] = 100 + i;
               dr["Model"] = GetChar(i) + i.ToString() + "DLJ";
               dr["Name"] = GetName(i) + i.ToString();
               dt.Rows.Add(dr);
           }
           return dt;
       }
   }

一.控件TokenEdit进行多个数据选择。
这里写图片描述
TokenEdit数据绑定:

List<Product> list = Entility.GetProductList();
            foreach (var item in list)
            {
                TokenEditToken token = new TokenEditToken() 
                {
                    Value=item.Id,Description=item.Name
                };
                tokenEdit1.Properties.Tokens.Add(token);
            }
    //值与值直接的分割符
            tokenEdit1.Properties.EditValueSeparatorChar = ',';

            string text = tokenEdit1.EditText;//以,分割的 item.Name
            string value = tokenEdit1.EditValue.ToString();//以,分割的 item.Id
阅读更多

扫码向博主提问

厦门德仔

博客专家

非学,无以致疑;非问,无以广识
  • 擅长领域:
  • ERP
  • .NET
  • SQL
  • Ext.Net
  • DevExpress
去开通我的Chat快问
换一批

没有更多推荐了,返回首页