Hide and reorganize the check boxes of TreeView

Source: Internet
Author: User

CheckBoxes is true

The Code is as follows:

using System.Runtime.InteropServices;

 

# The check box of the region tree hides private const int TVIF_STATE = 0x8; private const int TVIS_STATEIMAGEMASK = 0xF000; private const int TV _FIRST = 0x1100; private const int TVM_SETITEM = TV _FIRST + 63; [StructLayout (LayoutKind. sequential, Pack = 8, CharSet = CharSet. auto)] private struct TVITEM {public int mask; public IntPtr hItem; public int state; public int stateMask; [financialas (UnmanagedType. LPTStr)] public string lpszText; public int cchTextMax; public int iImage; public int iSelectedImage; public int cChildren; public IntPtr lParam;} [DllImport ("user32.dll", CharSet = CharSet. auto)] private static extern IntPtr SendMessage (IntPtr hWnd, int Msg, IntPtr wParam, ref TVITEM lParam ); /// <summary> /// Hides the checkbox for the specified node on a TreeView control. /// check box for hiding the tree /// <remarks> /// HideCheckBox (treeView1, node ); /// </remarks> /// </summary> private void HideCheckBox (TreeView tvw, TreeNode node) {TVITEM tvi = new TVITEM (); tvi. hItem = node. handle; tvi. mask = TVIF_STATE; tvi. stateMask = TVIS_STATEIMAGEMASK; tvi. state = 0; SendMessage (tvw. handle, TVM_SETITEM, IntPtr. zero, ref tvi);} # endregion

 

Usage

HideCheckBox(PerTreeView, rootTNode);

HideCheckBox (tree object, Node object );

The check box before the Node object is hidden.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.