Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ListView Gridline color

ListView Gridline color

Scheduled Pinned Locked Moved C#
css
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sibiks
    wrote on last edited by
    #1

    I have one listview which is owner drawn. I have to change the grid line color. I tried this by making GridLines = false for listview and Draw the gridlines programatically. But if there are 100 items its flickering and a lot of painting issues Sibi

    D 1 Reply Last reply
    0
    • S sibiks

      I have one listview which is owner drawn. I have to change the grid line color. I tried this by making GridLines = false for listview and Draw the gridlines programatically. But if there are 100 items its flickering and a lot of painting issues Sibi

      D Offline
      D Offline
      dengboo
      wrote on last edited by
      #2

      Where do you put the painting code? Paste your code, or it's hard to resolve it.

      --------------------------------- Believe what you saw!

      S 1 Reply Last reply
      0
      • D dengboo

        Where do you put the painting code? Paste your code, or it's hard to resolve it.

        --------------------------------- Believe what you saw!

        S Offline
        S Offline
        sibiks
        wrote on last edited by
        #3

        /// /// /// /// /// private void TreeListView_DrawItem( object sender, DrawListViewItemEventArgs e ) { Graphics g = e.Graphics; TreeListViewItem item = ( TreeListViewItem )e.Item; item.UpdateBounds(); this.DrawExpandMarker( g, item ); this.DrawCheckBox( g, item ); StringFormat sf = new StringFormat(); sf.LineAlignment = StringAlignment.Center; sf.FormatFlags = StringFormatFlags.NoWrap; SolidBrush foreBrush = new SolidBrush( this.ForeColor ); if( this.changeSelectionForeColor == true ) { foreBrush = new SolidBrush( item.ForeColor ); } SolidBrush fillBrush = new SolidBrush( item.BackColor ); Rectangle fillRect = e.Bounds; fillRect.X = item.TextBounds.X; fillRect.Width -= fillRect.X; fillRect.Height -= 1; if( item.Selected == true && item.ReadOnly == false && item.IsDummy == false ) { selectedItem = item; item.IsInvalidated = false; foreBrush = new SolidBrush( SystemColors.HighlightText ); if( this.changeSelectionForeColor == true ) { foreBrush = new SolidBrush( item.ForeColor ); } fillBrush = new SolidBrush( SystemColors.Highlight ); } g.FillRectangle( fillBrush, fillRect ); string text = this.GetAdjustedString( g, e.Item.Text, item.TextBounds, this.Font ); if( item.ReadOnly == false ) { g.DrawString( text, this.Font, foreBrush, item.TextBounds, sf ); } if( item.IsButtonNeeded == true ) { SolidBrush buttonBrush = new SolidBrush( this.Parent.BackColor ); Rectangle buttonRect = item.ButtonBounds; g.FillRectangle( buttonBrush, buttonRect ); Border3DStyle border = item.IsButtonPressed ? Border3DStyle.Adjust : Border3DStyle.RaisedInner; ControlPaint.DrawBorder3D( g, buttonRect, border ); sf.Alignment = StringAlignment.Center; this.Draw3DText( g, buttonRect, item.ButtonText, sf, item.IsButtonPressed );

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups