I have an intraweb form with a IWTreeview which has code in the ItemClick event. If you expand a node and select a child node, the form refreshes and the node collapses. How can the node be set expanded as it was previously? The issue is nothing to do with what the code is in ItemClick. It is how to get the treeview to remember that the node was open.
Related
I show items in a TTreeView object. When an Item has children the control paints a > next to the icon (or a down pointing arrow if expanded).
I was wondering if I can tell the Item somehow to paint the > even if no children have been added (yet).
There are certain conditions in my software where it makes sense to show the user there are children, without actually adding the children yet (That is then done when the item is selected)
Using c++ Builder 2009 VCL but this Q should be valid for Delphi as well.
In VCL, TTreeNode has a HasChildren property:
Indicates whether a node has any children.
HasChildren is true if the node has subnodes, or false if the node has no subnodes. If ShowButtons of the tree view is true, and HasChildren is true, a plus (+) button will appear to the left of the node when it is collapsed, and a minus (-) button will appear when the node is expanded.
Note: If a node has no children, setting HasChildren to true will show a (+) plus button, but will not add any child nodes and the node cannot be expanded.
So, you can set a node's HasChildren to true before actual child nodes have been created for it. Then later on, once you have determined whether the node has any actual child nodes, you can reset HasChildren to false if there are no child nodes present.
Despite what the documentation suggests above, attempting to expand a node that has no child nodes but does have HasChildren set to true WILL trigger the TTreeView.OnExpanding event, at least. That is a good place to populate the actual child nodes and update HasChildren.
I have a treepanel and a tabpanel. Each tree panel node corresponds to a tabpanel panel. When i click on a node, it gets highlighted and tab panel gets opened. Same way when i close the tab panel, the highlighting of node should be removed. I tried a lot, but could not succeed. Any help on this?
https://fiddle.sencha.com/#fiddle/1foo
you can see the listener on Abc.view.main.explorer.AbcTabPanel component.
Take a look at this: https://fiddle.sencha.com/#fiddle/1fq0
Your example threw a couple of errors which i've fixed in my example, but what i've basically done is this: i've attached a close listener to the created tab that checks the TreeList selection (getSelection). If the tab's record is the current selection, set selection to null. The TreeList will update its layout and unhighlight that record.
I hope this helps!
p.s. I've also done some minor code changes. That's just my coding style. If you don't like them, ignore them :)
using delphi ex-5
as of now, I can display the popupmenu on right click of a selected node
is it possible to display a icon on a treeview node (right side) on a moveover? When the icon is moused over, display a popupmenu?
thanx
EDIT: Inclusion of two screenshots to better convey my need (Yes, this was taken forom a webpage - it is what I am trying to do)
https://dl.dropboxusercontent.com/u/73677254/Delphi%20Demos/screenshot1.png
https://dl.dropboxusercontent.com/u/73677254/Delphi%20Demos/screenshot2.png
If you want the icon on the left side, you can use the TTreeNode.StateIndex property. But to put an icon on the right side, you have to owner-draw the TTreeView nodes instead.
Either way, use the TTreeView.OnMouseMove event to keep track of which node is currently under the mouse at all times, and when you detect a different node then you can reset the StateIndex of the previous node and update the StateIndex of the new node, or trigger a repaint and draw the icon only on the new node, depending on which approach you take.
I would like to build a Wizard component, where I can guid the user through different pages. When the last page is reached, an action is performed.
That component should work similar as the TPageControl, where I can create sheets at design-time. Creating that 'sheets' is already done, but my problem is, that the last added sheet is always on top of the other sheets, and I cannot select another one anymore (which are behind). In the TPageControl component, I can select a sheet in the Structure Pane, and it comes to the front, where can I put controls on it.
And this is my question: How can I bring a control (my wizard sheet) to the front, when it is selected in the Structre Pane?
I have to override the TWinControl.ShowControl function. That function is fired when you click in the structure pane on the child control. Then, I just need to invoke the BringToFront function of that child.
When you select multiple nodes of a JvTreeView, and then try to drag these nodes, the JvTreeView selects the node you clicked to drag, rather than initiating dragging all the selected nodes. You end up dragging only this single node.
Is it possible to drag multiple nodes in a JvTreeView? I am using Delphi 2007.
UPDATE: Oddly enough, if I hold down CTRL+SHIFT when dragging the items, I can successfully drag them all. Any ideas?
Suppose MultiSelectStyle is the default [msControlSelect], then the answer to your question is 'you don't release the control key when you're selecting the last item and beginning dragging'.
The culprit is in TJvTreeView.WMLButtonDown in JvComCtrls.pas. Code there tests if 'Ctrl' is pressed when the TreeView is MultiSelect, and clears all items and selects the clicked item if 'Ctrl' is not pressed. It should instead test if the clicked item is already selected and do nothing if it is.
You can see the broken behavior without dragging. Multi select a few items and then click a selected item with the mouse. The VCL TreeView do not select or de-select anything, while the JVTreeView, instead, de-selects all items and selects the clicked one.
Yes absolutely, I do it all the time.
Of course Multi-Select needs to be True and you may need to have a look at the TTreeView's MultiSelectStyle. That controls what type of nodes can be selected at the same time. For example if msSiblingOnly is set to true, you can only select sibblings.
Are you using dmAutomatic or dmManual. If the latter, it could be that you are doing something in the OnMouse* events that is negating the multi-selection you made earlier.