Tag Archives: removing

Selectively removing checkboxes in a .NET 1.1 / 2.0 TreeView

Earlier this month, I had the need to customise a TreeView control such that it had checkboxes against some, not all, of the nodes.

Here’s a screenshot of what I wanted:

Treeview

It requires a little bit of code to achieve this effect, but is was worth the effort. Here’s the code that performs the magic:

[code lang=”C#”]
using System.Runtime.InteropServices;

namespace Treeview___CheckBoxes
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
// Iterate over the root nodes, removing their checkboxes
for (int n = 0; nTechnorati Tags: , , ,