资源简介
C#的ListView添加各种自定义控件,CheckBox,ComboBox等

代码片段和文件信息
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;
namespace test
{
public partial class EXComboBox : ComboBox
{
private Brush _highlightbrush; //color of highlighted items
public EXComboBox()
{
_highlightbrush = SystemBrushes.Highlight;
this.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
this.DrawItem += new DrawItemEventHandler(this_DrawItem);
}
public Brush MyHighlightBrush
{
get { return _highlightbrush; }
set { _highlightbrush = value; }
}
private void this_DrawItem(object sender DrawItemEventArgs e)
{
if (e.Index == -1) return;
e.DrawBackground();
if ((e.State & DrawItemState.Selected) != 0)
{
e.Graphics.FillRectangle(_highlightbrush e.Bounds);
}
EXItem item = (EXItem)this.Items[e.Index];
Rectangle bounds = e.Bounds;
int x = bounds.X + 2;
if (item.GetType() == typeof(EXImageItem))
{
EXImageItem imgitem = (EXImageItem)item;
if (imgitem.MyImage != null)
{
Image img = imgitem.MyImage;
int y = bounds.Y + ((int)(bounds.Height / 2)) - ((int)(img.Height / 2)) + 1;
e.Graphics.DrawImage(img x y img.Width img.Height);
x += img.Width + 2;
}
}
else if (item.GetType() == typeof(EXMultipleImagesItem))
{
EXMultipleImagesItem imgitem = (EXMultipleImagesItem)item;
if (imgitem.MyImages != null)
{
for (int i = 0; i < imgitem.MyImages.Count; i++)
{
Image img = (Image)imgitem.MyImages[i];
int y = bounds.Y + ((int)(bounds.Height / 2)) - ((int)(img.Height / 2)) + 1;
e.Graphics.DrawImage(img x y img.Width img.Height);
x += img.Width + 2;
}
}
}
int fonty = bounds.Y + ((int)(bounds.Height / 2)) - ((int)(e.Font.Height / 2));
e.Graphics.DrawString(item.Text e.Font new SolidBrush(e.ForeColor) x fonty);
e.DrawFocusRectangle();
}
public class EXItem
{
private string _text = ““;
private string _value = ““;
public EXItem()
{
}
public EXItem(string text)
{
_text = text;
}
public string Text
{
get { return _text; }
set { _text = value; }
}
public string MyValue
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5470 2015-11-12 10:11 C#ListView中添加自定义控件\test\EXComboBox.cs
文件 35259 2015-11-12 10:13 C#ListView中添加自定义控件\test\EXListView.cs
文件 4183 2015-11-12 10:39 C#ListView中添加自定义控件\test\Form1.cs
文件 3337 2015-11-12 10:27 C#ListView中添加自定义控件\test\Form1.Designer.cs
文件 6017 2015-11-12 10:27 C#ListView中添加自定义控件\test\Form1.resx
文件 485 2015-11-12 10:08 C#ListView中添加自定义控件\test\Program.cs
文件 1358 2015-11-12 10:08 C#ListView中添加自定义控件\test\Properties\AssemblyInfo.cs
文件 2860 2015-11-12 10:08 C#ListView中添加自定义控件\test\Properties\Resources.Designer.cs
文件 5612 2015-11-12 10:08 C#ListView中添加自定义控件\test\Properties\Resources.resx
文件 1091 2015-11-12 10:08 C#ListView中添加自定义控件\test\Properties\Settings.Designer.cs
文件 249 2015-11-12 10:08 C#ListView中添加自定义控件\test\Properties\Settings.settings
文件 3849 2015-11-12 10:14 C#ListView中添加自定义控件\test\test.csproj
文件 854 2015-11-12 10:08 C#ListView中添加自定义控件\test.sln
..A..H. 20480 2015-11-12 10:27 C#ListView中添加自定义控件\test.suo
目录 0 2018-01-15 14:39 C#ListView中添加自定义控件\test\bin
目录 0 2015-11-12 10:08 C#ListView中添加自定义控件\test\Properties
目录 0 2018-01-15 14:39 C#ListView中添加自定义控件\test
目录 0 2018-01-15 14:38 C#ListView中添加自定义控件
----------- --------- ---------- ----- ----
91104 18
- 上一篇:C#winfrom 音乐播放器源码
- 下一篇:ArcEngine 时间滑块功能
相关资源
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
评论
共有 条评论