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. Visual Basic
  4. Column Color Change

Column Color Change

Scheduled Pinned Locked Moved Visual Basic
csharpgraphicshelp
2 Posts 1 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.
  • L Offline
    L Offline
    lespaul36
    wrote on last edited by
    #1

    I want to change the back color of a column in a listview control. I thought I was on the right track by capturing the backgrounderase message and then using this routine Try If Not Me.mcolSelectedCol.Equals(Nothing) And Not e.Header.Equals(Nothing) And Me.View = View.Details Then If Me.clv1.HeaderHandle.ToInt32 <> 0 Then 'Dim int As Integer = SendMessage(Me.clv1.HeaderHandle, Win32.WindowsMessages.HDM_GETITEMCOUNT, 0, 0) Dim rec As Win32.RECT = Me.arrRects(mintCurColumn) Dim sz As New Size(rec.right - rec.left, rec.bottom - rec.top) Dim g As Graphics = Graphics.FromHdc(e.Msg.WParam) g.FillRectangle(New SolidBrush(Color.Red), rec.left, Top, rec.right - rec.left, Height) End If End If Catch ex As Exception End Try But no luck as of yet. I have some c# code, but I can't seem to get through all the extra stuff to just pull this code. Any help would be great. TIA

    L 1 Reply Last reply
    0
    • L lespaul36

      I want to change the back color of a column in a listview control. I thought I was on the right track by capturing the backgrounderase message and then using this routine Try If Not Me.mcolSelectedCol.Equals(Nothing) And Not e.Header.Equals(Nothing) And Me.View = View.Details Then If Me.clv1.HeaderHandle.ToInt32 <> 0 Then 'Dim int As Integer = SendMessage(Me.clv1.HeaderHandle, Win32.WindowsMessages.HDM_GETITEMCOUNT, 0, 0) Dim rec As Win32.RECT = Me.arrRects(mintCurColumn) Dim sz As New Size(rec.right - rec.left, rec.bottom - rec.top) Dim g As Graphics = Graphics.FromHdc(e.Msg.WParam) g.FillRectangle(New SolidBrush(Color.Red), rec.left, Top, rec.right - rec.left, Height) End If End If Catch ex As Exception End Try But no luck as of yet. I have some c# code, but I can't seem to get through all the extra stuff to just pull this code. Any help would be great. TIA

      L Offline
      L Offline
      lespaul36
      wrote on last edited by
      #2

      Found how to do it. Friend Const LVM_SETSELECTEDCOLUMN As Integer = (LVM_FIRST + 140) SendMessage(lstView.Handle, Win32.WindowsMessages.LVM_SETSELECTEDCOLUMN, ColumnIndex, 0) lstview.invalidate()

      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