C#的WinForms突出树节点时,树状可是没有焦点 [英] C# WinForms highlight treenode when treeview doesnt have focus

查看:236
本文介绍了C#的WinForms突出树节点时,树状可是没有焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Gretings。

我正在编辑场景游戏的界面。基本上,它是由事件,其中有嵌套的条件和操作的。所以,我计划用两个树视图 - 一个用于选择的情况下,和其他用于选择要编辑的事件中的条件/动作

I'm making an interface to edit scenarios for a game. Basically it consists of events, which have nested conditions and actions. So, i planned using two treeviews - one for selecting the event, and other for selecting the condition/action inside the event to edit.

下面是如何看起来<一个href=\"http://img805.imageshack.us/img805/8835/18113044.png\">http://img805.imageshack.us/img805/8835/18113044.png

现在,你看,如果我选择一个事件(在左树视图),然后尝试选择正确的树状东西,左树视图将停止显示蓝色选择矩形。这显然​​是不好的,因为现在用户犯规知道哪些事件被他编辑!

Now, you see, if i select an event (in left treeview) and then try to select something in the right treeview, the left treeview will stop showing the blue selection rectangle. This is obviously bad because now the user doesnt know which event is he editing!

我发现保留某种关于什么是当前的选择是使用SelectedImageIndex信息,但唯一的办法只有那一个小小的图像,这将是不同的。

The only way i found to retain some sort of information about what is the current selection is by using SelectedImageIndex, but thats only one little image that will be different.

是否有任何其他的方式来突出树节点,而没有着眼于树状?我知道我可以只Graphics.DrawRectangle或东西,但我听说,图纸应在Paint事件做和TreeView没有油漆的事件,所以,我想如果我画它失去焦点的事件,然后拖动表格出了屏幕或什么的,它会被抹去?

Is there any other way to highlight the treenode while there is no focus on the treeview? I know i can just Graphics.DrawRectangle or something, but i heard that drawing should be done in Paint event and treeview has no paint event... So i guess if i draw it on the event of losing focus, and then drag the form out of the screen or something, it will be "erased"?

无论如何,请告诉我,如果你有一个想法(比使用单独的图标为其他选定和未选定树节点)

Anyway, please tell me if you got an idea (other than using a separate icon for selected and not selected treenode)

谢谢!

推荐答案

你所寻找的是在 TreeView控件的 HideSelection 属性

What you are looking for is the HideSelection property on the TreeView.

从MSDN:

获取或设置所选树节点是否保持突出显示,即使在树视图失去焦点的值。

Gets or sets a value indicating whether the selected tree node remains highlighted even when the tree view has lost the focus.

链接:<一个href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.hideselection.aspx\">http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.hideselection.aspx

code:

TreeView.HideSelection = false;

这篇关于C#的WinForms突出树节点时,树状可是没有焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆