Disable Checkbox in TreeView control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • James Lennon

    #1

    Disable Checkbox in TreeView control

    Does anyone know how to disable a single check box in a Windows Forms
    TreeView control.
  • Claes Bergefall

    #2
    Re: Disable Checkbox in TreeView control

    Handle the BeforeCheck event and cancel any attempts to check it.

    /claes

    "James Lennon" <JamesLennon@di scussions.micro soft.com> wrote in message
    news:93E845FC-C5E0-46C0-92E5-7BD23D87120B@mi crosoft.com...[color=blue]
    > Does anyone know how to disable a single check box in a Windows Forms
    > TreeView control.[/color]


    Comment

    • James Lennon

      #3
      Re: Disable Checkbox in TreeView control

      This will stop a user from checking the check box but the control does not
      look disabled. I can set the foreground color of the text but not the text
      box. Is there a way to get a handle to the actual text box.

      "Claes Bergefall" wrote:
      [color=blue]
      > Handle the BeforeCheck event and cancel any attempts to check it.
      >
      > /claes
      >
      > "James Lennon" <JamesLennon@di scussions.micro soft.com> wrote in message
      > news:93E845FC-C5E0-46C0-92E5-7BD23D87120B@mi crosoft.com...[color=green]
      > > Does anyone know how to disable a single check box in a Windows Forms
      > > TreeView control.[/color]
      >
      >
      >[/color]

      Comment

      • Claes Bergefall

        #4
        Re: Disable Checkbox in TreeView control

        I assume you mean checkbox (you wrote text box). The checkbox is just an
        image in the state image list for the tree view (Windows generates 2 images
        for you, one checked checkbox and one unchecked) so simply changing the
        state image index for the node should work. Ofc, you'll need to add the
        image for a disabled checkbox first. You can also replace the images with
        your own if you'ld like. Here are some threads that might be of interest:




        /claes

        "James Lennon" <JamesLennon@di scussions.micro soft.com> wrote in message
        news:29A359A5-7E71-44F1-BAD3-A09A703C5F43@mi crosoft.com...[color=blue]
        > This will stop a user from checking the check box but the control does not
        > look disabled. I can set the foreground color of the text but not the
        > text
        > box. Is there a way to get a handle to the actual text box.
        >
        > "Claes Bergefall" wrote:
        >[color=green]
        >> Handle the BeforeCheck event and cancel any attempts to check it.
        >>
        >> /claes
        >>
        >> "James Lennon" <JamesLennon@di scussions.micro soft.com> wrote in message
        >> news:93E845FC-C5E0-46C0-92E5-7BD23D87120B@mi crosoft.com...[color=darkred]
        >> > Does anyone know how to disable a single check box in a Windows Forms
        >> > TreeView control.[/color]
        >>
        >>
        >>[/color][/color]


        Comment

        Working...