TreeView的复选框隐藏 重新整理
生活随笔
收集整理的這篇文章主要介紹了
TreeView的复选框隐藏 重新整理
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
CheckBoxes 為真
代碼如下
using System.Runtime.InteropServices;?
#region 樹的復選框隱藏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;[MarshalAs(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./// 隱藏樹的復選框/// <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?
使用方法
HideCheckBox(PerTreeView, rootTNode);HideCheckBox(樹對象, 節點對象);
節點對象前的復選框則隱藏了
?
?
轉載于:https://www.cnblogs.com/DoNetCShap/archive/2012/06/26/2563119.html
總結
以上是生活随笔為你收集整理的TreeView的复选框隐藏 重新整理的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: pku 3159 Candies 差分约
- 下一篇: javascript 运算优先级