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. Windows Forms
  4. checkedlistbox item height [modified]

checkedlistbox item height [modified]

Scheduled Pinned Locked Moved Windows Forms
graphicstutorial
5 Posts 3 Posters 22 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
    ScottM1
    wrote on last edited by
    #1

    Hallo Does anybody know how to change the height of an item in a checkedlistbox control. I have tried setting the drawmode to OwnerDrawVariable and drawing each item myself but with no success. Any clues would be greatly appreciated. Thanks -- modified at 1:47 Tuesday 15th May, 2007

    There are 10 types of people in the world, those who understand binary and those who dont.

    B D 2 Replies Last reply
    0
    • S ScottM1

      Hallo Does anybody know how to change the height of an item in a checkedlistbox control. I have tried setting the drawmode to OwnerDrawVariable and drawing each item myself but with no success. Any clues would be greatly appreciated. Thanks -- modified at 1:47 Tuesday 15th May, 2007

      There are 10 types of people in the world, those who understand binary and those who dont.

      B Offline
      B Offline
      Blumen
      wrote on last edited by
      #2

      When the DrawMode property is set to DrawMode.OwnerDrawFixed, all items have the same height. When the DrawMode property is set to DrawMode.OwnerDrawVariable, the ItemHeight property specifies the height of each item added to the ListBox. Because each item in an owner-drawn list can have a different height, you can use the GetItemHeight method to get the height of a specific item in the ListBox. If you use the ItemHeight property on a ListBox with items of variable height, this property returns the height of the first item in the control.

      S 1 Reply Last reply
      0
      • B Blumen

        When the DrawMode property is set to DrawMode.OwnerDrawFixed, all items have the same height. When the DrawMode property is set to DrawMode.OwnerDrawVariable, the ItemHeight property specifies the height of each item added to the ListBox. Because each item in an owner-drawn list can have a different height, you can use the GetItemHeight method to get the height of a specific item in the ListBox. If you use the ItemHeight property on a ListBox with items of variable height, this property returns the height of the first item in the control.

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

        That only works for a listbox though. If you try that on a checkedlistbox it wont work. The checkedlistbox is inherited from the listbox and hardcodes the height to its fontsize + 2. The only way to change the height is to change the font size or alternatively draw the checkboxes to an ordinary listbox that is set to OwnerDrawVariable. Thanks though, you wouldn't believe how long I was stuck on this :doh:

        There are 10 types of people in the world, those who understand binary and those who dont.

        1 Reply Last reply
        0
        • S ScottM1

          Hallo Does anybody know how to change the height of an item in a checkedlistbox control. I have tried setting the drawmode to OwnerDrawVariable and drawing each item myself but with no success. Any clues would be greatly appreciated. Thanks -- modified at 1:47 Tuesday 15th May, 2007

          There are 10 types of people in the world, those who understand binary and those who dont.

          D Offline
          D Offline
          Dougie the P
          wrote on last edited by
          #4

          This works in VS2013 net FrameWork4.5 Put declare and constant at top of class Usage put rest of code in Form_Load as in example code.

          Private Declare Function SendMessageByNum Lib "user32" Alias "SendMessageA" _
          (ByVal hwnd As IntPtr, ByVal wMsg As UInt32, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr

          Private Const lB_SETITEMHEIGHT As Integer = &H1A0

          Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

          Dim ItemHeight As Integer = Me.Font.Height + 4
          SendMessageByNum(CheckedListBoxControl.Handle, lB\_SETITEMHEIGHT, CType(0, IntPtr), CType(ItemHeight, IntPtr))
          

          End Sub

          Douglas Peterson Senior Application Developer / Chief Technical Officer The Professional PC / ERIC Systems

          S 1 Reply Last reply
          0
          • D Dougie the P

            This works in VS2013 net FrameWork4.5 Put declare and constant at top of class Usage put rest of code in Form_Load as in example code.

            Private Declare Function SendMessageByNum Lib "user32" Alias "SendMessageA" _
            (ByVal hwnd As IntPtr, ByVal wMsg As UInt32, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr

            Private Const lB_SETITEMHEIGHT As Integer = &H1A0

            Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

            Dim ItemHeight As Integer = Me.Font.Height + 4
            SendMessageByNum(CheckedListBoxControl.Handle, lB\_SETITEMHEIGHT, CType(0, IntPtr), CType(ItemHeight, IntPtr))
            

            End Sub

            Douglas Peterson Senior Application Developer / Chief Technical Officer The Professional PC / ERIC Systems

            S Offline
            S Offline
            ScottM1
            wrote on last edited by
            #5

            Thanks, I've been trying to figure this out for 8 years, I can finally move on with my life now :laugh:

            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