zoukankan      html  css  js  c++  java
  • 转的: 重绘ListView 修改标题颜色

    1、owerDraw 设置为true

    2、实现事件

    DrawColumnHeader

    DrawItem

    DrawSubItem

    private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
    {
    int tColumnCount;
    Rectangle tRect = new Rectangle();
    Point tPoint = new Point();
    Font tFont = new Font("宋体", FontSize, FontStyle.Regular);
    SolidBrush tBackBrush = new SolidBrush(System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(255))))));
    SolidBrush tFtontBrush;
    tFtontBrush = new SolidBrush(System.Drawing.SystemColors.GradientActiveCaption);

    if (listView1.Columns.Count == 0)
    return;

    tColumnCount = listView1.Columns.Count;
    tRect.Y = 0;
    tRect.Height = e.Bounds.Height - 1;
    tPoint.Y = sWidth;
    for (int i = 0; i < tColumnCount; i++)
    {
    if (i == 0)
    {
    tRect.X = 0;
    tRect.Width = listView1.Columns[i].Width;
    }
    else
    {
    tRect.X += tRect.Width;
    tRect.X += 1;
    tRect.Width = listView1.Columns[i].Width - 1;
    }
    e.Graphics.FillRectangle(tBackBrush, tRect);
    tPoint.X = tRect.X + sWidth;
    e.Graphics.DrawString(listView1.Columns[i].Text, tFont, tFtontBrush, tPoint);
    }

    }

    private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
    {
    Point tPoint = new Point();
    SolidBrush tFrontBrush = new SolidBrush(Color.Blue);
    Font tFont = new Font("宋体", FontSize, FontStyle.Regular);
    tPoint.X = e.Bounds.X + 3;
    tPoint.Y = e.Bounds.Y + 2;
    e.Graphics.DrawString(e.Item.Text, tFont, tFrontBrush, tPoint);
    }

    private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
    {
    Point tPoint = new Point();
    SolidBrush tFrontBrush = new SolidBrush(Color.Blue);
    Font tFont = new Font("宋体", FontSize, FontStyle.Regular);
    tPoint.X = e.Bounds.X + 3;
    tPoint.Y = e.Bounds.Y + 2;
    e.Graphics.DrawString(e.SubItem.Text, tFont, tFrontBrush, tPoint);
    }

  • 相关阅读:
    etcd基本操作
    使用docker配置etcd集群
    etcd启用https服务
    etcd3集群管理
    Opengl绘制我们的小屋(一)球体,立方体绘制
    OpenGL 用三角形模拟生成球面
    PDFSharp生成PDF.
    OpenXml操作Word的一些操作总结.无word组件生成word.
    F# 图形数学基础。
    SQL Server (MSSQLSERVER) 服务因 2148081668 服务性错误而停止。
  • 原文地址:https://www.cnblogs.com/china-guoch/p/4866266.html
Copyright © 2011-2022 走看看