当前位置: 网站首页 > .NET > c#

C#设计带图标和自定义颜色的ListBox

时间:1970-1-1 08:33:31来源: c#作者:admin 点击:5次 字体 [ С]

// If the image list is present and the image index is set, draw the image

 if(this.imageList != null)
 {
  if (item.ImageIndex > -1 && item.ImageIndex < this.imageList.Images.Count)
  {
    this.imageList.Draw(pe.Graphics, bounds.Left, bounds.Top, bounds.Height, bounds.Height, item.ImageIndex); //绘制图标
  }
  iOffset += bounds.Height;//this.imageList.ImageSize.Width;
 }

 // Draw item text

 pe.Graphics.DrawString(item.Text, pe.Font, new SolidBrush(item.ForeColor),bounds.Left + iOffset, bounds.Top); //根据项的颜色绘制文本

 }
 base.OnDrawItem(pe);
 }
}

  到此为止,ListBoxEx以完整的实现,并且支持可视化设计。


图文资讯
发表评论
验证码:
最新评论
相关文章
最新文章
最热文章