GridControl应用

一 绑定

1.绑定动态图片

 #region 方法:设置图片列(图片+文字)
        public static void SetColumnToPicture(DevExpress.XtraGrid.Views.Grid.GridView gridView)
        { 
           ImageList imgList = new ImageList();  
          imgList.TransparentColor = Color.Transparent;  
          imgList.ImageSize = new Size(16, 16);  
          imgList.ColorDepth = ColorDepth.Depth32Bit;

          Image img0 = Properties.Resources.Retina_Ready_24px_1142019_easyicon_net;       
          Image img1 = Properties.Resources.Hourglass_24px_1102301_easyicon_net;
          Image img2 = Properties.Resources.Success_24px_1194837_easyicon_net;
          imgList.Images.Add("0", img0);  
          imgList.Images.Add("1", img1);  
          imgList.Images.Add("2", img2);          
  
          RepositoryItemImageComboBox riImgCmb = new  RepositoryItemImageComboBox();  
         riImgCmb.Items.AddRange(new ImageComboBoxItem[]
         {  
               new ImageComboBoxItem("待 上 传",0,0),  
               new ImageComboBoxItem( "已 上 传" ,1,1),                                                                      
               new ImageComboBoxItem("已 提 交",2,2),              
         }); 
          riImgCmb.SmallImages = imgList;
          gridView.Columns["UploadStatus"].ColumnEdit = riImgCmb;     
        }
        #endregion

2.绑定动态:repositoryItemPopupContainerEdit

 

二.编辑表格

  编辑表格其实是对数据源的操作,所以如需编辑必定要有数据源,哪怕是空表。

 

  #region 方法:创建空表(待上传Dt)
        public static DataTable CreateDtForWaitUpload()
        {
            DataTable dt = new DataTable();
            dt.Columns.AddRange(
             new DataColumn[]
             {                   
                   new DataColumn("ID",typeof(string)),
                    new DataColumn("FilePath",typeof(string)),
                    new DataColumn("FileName",typeof(string)),
                    new DataColumn("UploadTypeName",typeof(string)),
                    new DataColumn("FileSize",typeof(string)), 
                    new DataColumn("FileContent",typeof(byte[])),
                     new DataColumn("UploadStatus",typeof(int)), 
                     new DataColumn("UploadStatusImage",typeof(Byte[])),
                      
                }
                   );
            return dt;
        }
        #endregion

 

posted @ 2019-08-31 15:32  马玲  阅读(194)  评论(0)    收藏  举报