当我编辑树节点(名称很长)时,它有一个背景颜色:
如何去除背景?如何更改背景颜色?
我试图在 OnDrawNode 中删除它,但这是不可能的。接下来,我尝试使用 TVM_GETEDITCONTROL 消息并发送 WM_CTLCOLOREDIT,但它也不起作用:
[DllImport("user32.dll")]
internal static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
internal const int WM_CTLCOLOREDIT = 0x0133;
internal const int TVM_GETEDITCONTROL = 0x110F;
private void NodeTree_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e)
{
TreeNode nodeEditing = e.Node;
IntPtr editControlHandle = SendMessage(NodeTree.Handle, (uint)TVM_GETEDITCONTROL, IntPtr.Zero, IntPtr.Zero);
if (editControlHandle != IntPtr.Zero)
{
SendMessage(editControlHandle, (uint)WM_CTLCOLOREDIT, ColorTranslator.ToWin32(Color.Red), new IntPtr(1));
}
}