TreeView CheckBox Alignment RRS feed

  • General discussion


    I am using a TreeView control. I have the follwoing combination of properties which causes the check boxes not to be vertically aligned on center, they are always below. The node text and node image is on center. Is there a way to align the chack boxes?


    CheckBoxes = True

    Font | Size = 14 pt

    ItemHeight = 24

    Monday, February 4, 2008 8:49 PM

All replies

  • Hi Fwk,


    To know about your problem, we really need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

    Best regards,


    Friday, February 8, 2008 6:03 AM
  • Sorry for the delay in response, the alert me funtion of the forum was not alerting me!


    I have copied the source code from the form designer. The project has no other settings or code. The issue can be seen by dragging a treeview from the toolbox onto the form and adding a node. I then set the following properties in the property grid, font size, height, indent and of course checkbox. In this examle I have a font size of 19.8. The issue occurs at any font size that is larger than the 8.25 default.


    Code Snippet

    'Required by the Windows Form Designer

    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer

    'It can be modified using the Windows Form Designer.

    'Do not modify it using the code editor.

    <System.Diagnostics.DebuggerStepThrough()> _

    Private Sub InitializeComponent()

    Dim TreeNode1 As System.Windows.Forms.TreeNode = New System.Windows.Forms.TreeNode("Node1")

    Dim TreeNode2 As System.Windows.Forms.TreeNode = New System.Windows.Forms.TreeNode("Node2")

    Dim TreeNode3 As System.Windows.Forms.TreeNode = New System.Windows.Forms.TreeNode("Node0", New System.Windows.Forms.TreeNode() {TreeNode1, TreeNode2})

    Me.TreeView1 = New System.Windows.Forms.TreeView





    Me.TreeView1.CheckBoxes = True

    Me.TreeView1.Font = New System.Drawing.Font("Microsoft Sans Serif", 19.8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

    Me.TreeView1.Indent = 32

    Me.TreeView1.ItemHeight = 40

    Me.TreeView1.Location = New System.Drawing.Point(12, 12)

    Me.TreeView1.Name = "TreeView1"

    TreeNode1.Name = "Node1"

    TreeNode1.Text = "Node1"

    TreeNode2.Name = "Node2"

    TreeNode2.Text = "Node2"

    TreeNode3.Name = "Node0"

    TreeNode3.Text = "Node0"

    Me.TreeView1.Nodes.AddRange(New System.Windows.Forms.TreeNode() {TreeNode3})

    Me.TreeView1.Size = New System.Drawing.Size(231, 143)

    Me.TreeView1.TabIndex = 0




    Me.AutoScaleDimensions = New System.Drawing.SizeF(15.0!, 30.0!)

    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

    Me.ClientSize = New System.Drawing.Size(256, 170)


    Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 19.8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

    Me.Margin = New System.Windows.Forms.Padding(8, 7, 8, 7)

    Me.Name = "Form1"

    Me.Text = "Form1"


    End Sub



    Thursday, March 27, 2008 2:33 PM