初始化提交
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace JinYuan.ControlLib
|
||||
{
|
||||
public partial class ListViewEx : ListView
|
||||
{
|
||||
|
||||
StringFormat sf = new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center };//字体水平位置居左,垂直居中
|
||||
|
||||
public ListViewEx()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.OwnerDraw = true;
|
||||
}
|
||||
|
||||
public ListViewEx(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
private Brush bgColor = Brushes.DodgerBlue;
|
||||
[CategoryAttribute("自定义")]
|
||||
[DescriptionAttribute("背景颜色")]
|
||||
public Brush BgColor
|
||||
{
|
||||
set
|
||||
{
|
||||
bgColor = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return bgColor;
|
||||
}
|
||||
}
|
||||
|
||||
private Brush fontColor = Brushes.White;
|
||||
[CategoryAttribute("自定义")]
|
||||
[DescriptionAttribute("字体颜色")]
|
||||
public Brush FontColor
|
||||
{
|
||||
set
|
||||
{
|
||||
fontColor = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return fontColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
|
||||
{
|
||||
//e.DrawBackground();
|
||||
e.Graphics.FillRectangle(BgColor, e.Bounds); //设置背景颜色
|
||||
Font font = new Font("微软雅黑", 12, FontStyle.Bold); //设置字体大小
|
||||
e.Graphics.DrawString(e.Header.Text, font, FontColor, e.Bounds, sf); //设置字体颜色
|
||||
}
|
||||
|
||||
protected override void OnDrawItem(DrawListViewItemEventArgs e)
|
||||
{
|
||||
e.DrawDefault = true; //采用系统默认方式绘制项
|
||||
}
|
||||
|
||||
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
|
||||
{
|
||||
e.DrawDefault = true; //采用系统默认方式绘制项
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user