资源简介
上次上传的大家说有问题,是我没演示怎么使用items属性,我进行了改进,
大家可以看看类似datagrid的列属性items是怎么实现的。代码注视完整,开发平台vs2005,代码语言C#。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.xml.Serialization;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Configuration;
namespace ControlItems
{
public class ControlItem : UserControl
{
#region 构造方法
private void InitializeComponent()
{
this.SuspendLayout();
//
// ControlItem
//
this.AllowDrop = true;
this.Name = “ControlItem“;
this.ResumeLayout(false);
}
#endregion
#region 控件属性及隐藏属性
///
/// 编辑其Items
///
private named[] names = new named[] { };
public named[] Items
{
get { return names; }
set { names = value; }
}
///
/// 前景颜色
///
private Color forecolor = Color.Black;
///
/// 背景颜色
///
private Color backcolor = Color.Red;
///
/// 前景颜色
///
public Color Forecolor
{
get { return forecolor; }
set { forecolor = value; }
}
///
/// 背景颜色
///
public Color Backcolor
{
get { return backcolor; }
set { backcolor = value; }
}
///
/// 当前选中的items
///
private int itemsNow = -1;
///
/// 上次选中的items
///
private int itemsOld = -1;
///
/// 当前选中的items
///
[Browsable(false)]
public int ItemsNow
{
get { return itemsNow; }
set { itemsNow = value; }
}
///
/// 上次选中的items
///
[Browsable(false)]
public int ItemsOld
{
get { return itemsOld; }
set { itemsOld = value; }
}
#endregion
#region 重写绘制方法,使得items能够显示
///
/// 绘制named的names
///
///
protected override void OnPaint(PaintEventArgs e)
{
int flag = 0; //用于控制Items的起始Y坐标
foreach (named var in names)
{
if (((named)(var)).Fouce == false)
{
//文本
string str = ((named)(var)).Text;
System.Drawing.Graphics myGraphics = e.Graphics;
System.Drawing.Font dd = new System.Drawing.Font(“宋体“ 9);
System.Drawing.RectangleF textf = new System.Drawing.RectangleF(10 10 + flag ((named)(var)).Withed + 10 ((named)(var))
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9884 2012-03-19 17:57 ControlItems\ControlItem.cs
文件 5814 2012-02-27 17:07 ControlItems\ControlItem.resx
文件 24576 2012-10-21 20:11 ControlItems\ControlItems\bin\Debug\ControlItems.exe
文件 40448 2012-10-21 20:11 ControlItems\ControlItems\bin\Debug\ControlItems.pdb
文件 5632 2005-12-08 14:51 ControlItems\ControlItems\bin\Debug\ControlItems.vshost.exe
文件 1278 2012-02-27 14:15 ControlItems\ControlItems\Class1.cs
文件 9884 2012-03-19 17:57 ControlItems\ControlItems\ControlItem.cs
文件 5814 2012-02-27 17:07 ControlItems\ControlItems\ControlItem.resx
文件 3539 2012-03-19 17:43 ControlItems\ControlItems\ControlItems.csproj
文件 522 2012-10-21 20:11 ControlItems\ControlItems\Form1.cs
文件 3391 2012-10-21 20:11 ControlItems\ControlItems\Form1.Designer.cs
文件 5814 2012-10-21 20:11 ControlItems\ControlItems\Form1.resx
文件 2199 2012-10-28 20:45 ControlItems\ControlItems\obj\ControlItems.csproj.FileListAbsolute.txt
文件 180 2012-08-21 09:55 ControlItems\ControlItems\obj\Debug\ControlItems.ControlItem.resources
文件 906 2012-10-21 20:11 ControlItems\ControlItems\obj\Debug\ControlItems.csproj.GenerateResource.Cache
文件 24576 2012-10-21 20:11 ControlItems\ControlItems\obj\Debug\ControlItems.exe
文件 180 2012-10-21 20:11 ControlItems\ControlItems\obj\Debug\ControlItems.Form1.resources
文件 40448 2012-10-21 20:11 ControlItems\ControlItems\obj\Debug\ControlItems.pdb
文件 180 2012-08-21 09:55 ControlItems\ControlItems\obj\Debug\ControlItems.Properties.Resources.resources
文件 471 2012-03-19 17:43 ControlItems\ControlItems\Program.cs
文件 1196 2011-12-14 10:09 ControlItems\ControlItems\Properties\AssemblyInfo.cs
文件 2880 2011-12-14 10:09 ControlItems\ControlItems\Properties\Resources.Designer.cs
文件 5612 2011-12-14 10:09 ControlItems\ControlItems\Properties\Resources.resx
文件 1097 2011-12-14 10:09 ControlItems\ControlItems\Properties\Settings.Designer.cs
文件 249 2011-12-14 10:09 ControlItems\ControlItems\Properties\Settings.settings
文件 925 2011-12-14 10:09 ControlItems\ControlItems.sln
..A..H. 39424 2012-10-28 21:09 ControlItems\ControlItems.suo
目录 0 2011-12-14 10:43 ControlItems\ControlItems\obj\Debug\Refactor
目录 0 2011-12-14 10:09 ControlItems\ControlItems\obj\Debug\TempPE
目录 0 2012-08-21 09:55 ControlItems\ControlItems\bin\Debug
............此处省略42个文件信息
- 上一篇:最新淘宝客C#.NET基础API代码和SDK
- 下一篇:酒店预订管理系统系统结构图
相关资源
- C# TIP文件生成和拆解
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- 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#版保龄球记分代码
评论
共有 条评论