Expand items using code
-
- Cadet
- Posts: 2
- Joined: 26 Dec 2005, 13:47
Expand items using code
Hi Timo,
I have selected an item that is also deep in the tree. I now want to expand the tree towards the newly selected item. Is there a function that does this ?
Kind regards,
Chris Haarmeijer
I have selected an item that is also deep in the tree. I now want to expand the tree towards the newly selected item. Is there a function that does this ?
Kind regards,
Chris Haarmeijer
Hi,
the EnsureVisible method should be what you're looking for.
the EnsureVisible method should be what you're looking for.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
The EnsureVisible method ensures that an item is visible, i. e. if it is not visible, it is scrolled into view and parent items are expanded just as necessary. The return value of this method tells you whether any item expansions took place in order to make the item visible.
Isn't that what you want? Maybe I misunderstood your question. If you want to simply set the expansion state of an item, take a look at its ExpansionState property and/or its Collapse and Expand methods.
TiKu
Isn't that what you want? Maybe I misunderstood your question. If you want to simply set the expansion state of an item, take a look at its ExpansionState property and/or its Collapse and Expand methods.
TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Ah, you want to hide items. Well, this is not possible.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!

No, no hiding. The thing I want is that when a user selects an item in a different control, I want to jump straight to that item in the treeview. EnsureVisible sounds right, but the problem is this:
inline VARIANT_BOOL ITreeViewItem::EnsureVisible ( ) {
VARIANT_BOOL _result = 0;
HRESULT _hr = raw_EnsureVisible(&_result);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _result;
}
A piece of code generated by the ocx. As you can see here, I cannot change the property of an item using the ensurevisible function. It is a <get> property, not a <set> property. I do not want to hide an item, but I want to jump straight to it (expands all parents until that item is reached). I can do this in a couple of lines of code, but in the original tree control of Windows, you can use the expand function to do this.
Sorry for the hassle and mixup in what I want to do.
Chris
So you probably have not understood how EnsureVisible is working. You get the ITreeViewItem interface of the item for which you want to ensure visibility and call EnsureVisible on this item. EnsureVisible wraps the TVM_ENSUREVISIBLE message.
If you can't get it working, you may also use something like this:
HTH
TiKu
If you can't get it working, you may also use something like this:
Code: Select all
//pseudo code
SendMessage(hWndTvw, TVM_ENSUREVISIBLE, 0, LongToHandle(pTreeViewItem->get_Handle()));
TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
What do you want to pass to EnsureVisible? You don't pass any boolean value with TVM_ENSUREVISIBLE either. So what do you want to pass to the EnsureVisible method? :dontknow:
/edit: EnsureVisible is not a property, it is a method.
/edit: EnsureVisible is not a property, it is a method.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!