zoukankan      html  css  js  c++  java
  • 如何设置ListView控件中的列头的颜色!

          ListView默认的列头的背景太单调,缺乏个性,想变的列头的背景色!

          实际上可以使用ListViewDrawColumnHeader事件自己画背景色,注意仅当 OwnerDraw 属性设置为 true View 属性设置为 View. Details 时才引发此事件!不多说了,大家看代码,过程很简单:

    private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
    {
          e.Graphics.FillRectangle(Brushes.Red, e.Bounds); //采用特定颜色绘制标题列,这里我用的红色
          e.DrawText(); //采用默认方式绘制标题文本 }
          实际上Item和SubItem也可以自己来画外观的,使用DrawItem和DrawSubItem事件就可以了:
    private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e) {       e.Graphics.FillRectangle(Brushes.Red, e.Bounds); //采用特定颜色绘制标题列,这里我用的红色
          e.DrawText(); //采用默认方式绘制标题文本 }
    private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
    {
          e.Graphics.FillRectangle(Brushes.Red, e.Bounds); //采用特定颜色绘制标题列,这里我用的红色
          e.DrawText(); //采用默认方式绘制标题文本
    }
  • 相关阅读:
    hdu3829(最大独立集)
    hdu2444(判二分图+最大匹配)
    hdu2063+hdu1083(最大匹配数)
    hdu3622(二分+two-sat)
    poj3678(two-sat)
    hdu1824(two-sat)
    hdu3062(two-sat)
    POJ1067 取石子游戏
    POJ1066 Treasure Hunt
    POJ1065 Wooden Sticks
  • 原文地址:https://www.cnblogs.com/chuncn/p/1522594.html
Copyright © 2011-2022 走看看