• VS2003 下GridControl的列显示成图片+文字的形式实现


            public RC_CustomerSolicitListUC()
            {
                // 该调用是 Windows.Forms 窗体设计器所必需的。
                InitializeComponent();
    
                // TODO: 在 InitializeComponent 调用后添加任何初始化
    
                //ADD BY TWH 2013-09-23,状态列显示为图片+文字的形式
                SetStatusWithPic(gridView1, gridColumnStatus, false);
    
            }
    
            private void SetStatusWithPic(GridView aGridView1, GridColumn aColStatus, bool aOnlyImage)
            {
                ImageList imageList = new ImageList();
                imageList.ImageSize = new Size(12, 12);
                imageList.ColorDepth = ColorDepth.Depth32Bit;
                imageList.Images.Add(GetImage("待招揽.png"));
                imageList.Images.Add(GetImage("招揽中.png"));
                imageList.Images.Add(GetImage("待招揽复谈.png"));
                imageList.Images.Add(GetImage("待现场促进.png"));
                imageList.Images.Add(GetImage("待经理复谈.png"));
                imageList.Images.Add(GetImage("已成交.png"));
                imageList.Images.Add(GetImage("已战败.png"));
             
    
                imageList.TransparentColor = Color.Transparent;
    
                RepositoryItemImageComboBox repositoryItemImageComboBoxStatus = new RepositoryItemImageComboBox();
    //            aColStatus.ToolTip = "状态";
                if (aOnlyImage)
                {
                    aColStatus.Width = 22;
    
                    repositoryItemImageComboBoxStatus.Items.AddRange(new ImageComboBoxItem[]
                    {
                        new ImageComboBoxItem("",CustAllocStatus.PRE_SOLICIT,0),
                        new ImageComboBoxItem("",CustAllocStatus.SOLICITING,1),
                        new ImageComboBoxItem("",CustAllocStatus.PRE_SOLICIT_TALK,2),
                        new ImageComboBoxItem("",CustAllocStatus.PRE_PROMOTE,3),
                        new ImageComboBoxItem("",CustAllocStatus.PRE_MANAGER_TALK,4),
                        new ImageComboBoxItem("",CustAllocStatus.DEALED,5),
                        new ImageComboBoxItem("",CustAllocStatus.DEFEATED,6),
                    });
                }
                else
                {
                    repositoryItemImageComboBoxStatus.Items.AddRange(new ImageComboBoxItem[]
                    {
                        new ImageComboBoxItem("待招揽",CustAllocStatus.PRE_SOLICIT,0),
                        new ImageComboBoxItem("招揽中",CustAllocStatus.SOLICITING,1),
                        new ImageComboBoxItem("待招揽复谈",CustAllocStatus.PRE_SOLICIT_TALK,2),
                        new ImageComboBoxItem("待现场促进",CustAllocStatus.PRE_PROMOTE,3),
                        new ImageComboBoxItem("待经理复谈",CustAllocStatus.PRE_MANAGER_TALK,4),
                        new ImageComboBoxItem("已成交",CustAllocStatus.DEALED,5),
                        new ImageComboBoxItem("已战败",CustAllocStatus.DEFEATED,6),
                    });
                }
                repositoryItemImageComboBoxStatus.Name = "repositoryItemImageComboBoxStatus";
                repositoryItemImageComboBoxStatus.SmallImages = imageList;
                //
                aColStatus.ColumnEdit = repositoryItemImageComboBoxStatus;
            }
    
    
            private Image GetImage(string aFileName)
            {
                // 从当前类型所在程序集里面提取“嵌入的资源文件”
                return new Bitmap(this.GetType(), aFileName);
            }

    特别注意:增加的图片一定要与UC控件在同一文件夹下否则GetImage方法会无法读取到图片资源,当然在VS2005后VS都自带有Resources资源类,就不用像VS2003那样有较大的限制了。可以直接从Resources中读取

  • 相关阅读:
    mysql之流程控制函数
    JavaWeb项目部署到Linux服务器
    Node.js 的核心模块
    mysql之其他函数
    [导入]dotNet学习笔记-浅谈.Net的事件代理
    [导入]全国人民在为谁卖命?剩余价值输向发达国家的另一条管道优秀的上市公司
    [导入]dotNet学习笔记-浅谈.Net的事件代理
    [导入]dotNet学习笔记-浅谈.Net的事件代理
    [导入]创建一个没有窗口的程序
    [导入]设计模式Top10排行榜
  • 原文地址:https://www.cnblogs.com/ShaYeBlog/p/3335234.html
Copyright © 2020-2023  润新知