一、给GridControl添加按钮列 

 

   最近搞项目,要给CrigControl添加按钮列。由于英文不好走了很多弯路。

   现在终于搞好了。。

   写下来,以防以后忘记

   把列的ColumnEdit属性设置为RepositoryItemButtonEdit

   把TextEditStyle属性设置为HideTextEditor;

   把Buttons的Kind属性设置为Glyph;

   把Buttons的HorzAlignment属性设置为Near;

   如果要用到事件的话,还要注册事件。。。

   列名.ButtonClick += new ButtonPressedEventHandler(列名_ButtonClick);

二、gridcontrol中的cardview中 图片不显示的问题

 

//显示数据

       private void showData()

       {

           DataTable dt = new DataTable("OneEmployee");

           dt.Columns.Add("Caption", System.Type.GetType("System.String"));

           dt.Columns.Add("Department", System.Type.GetType("System.String"));

           dt.Columns.Add("PhotoName", System.Type.GetType("System.Byte[]"));


             DataRow dr = dt.NewRow();

              dr["Caption"] = list[i].Name;

              dr["Department"] = list[i].Department;

              string imagePath = @"D:/C#/photos/" + list[i].PhotoPath;

               dr["PhotoName"] = getImageByte(imagePath);

              dt.Rows.Add(dr);

            gridControl1.DataSource = dt;

       }

       //返回图片的字节流byte[]

        private byte[] getImageByte(string imagePath)

       {

           FileStream files = new FileStream(imagePath, FileMode.Open);

         byte[] imgByte = new byte [files.Length ];

         files.Read(imgByte, 0, imgByte.Length);

         files.Close();

          return imgByte;

      }