This is a migrated thread and some comments may be shown as answers.

RadTreeView

10 Answers 273 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
dmm
Top achievements
Rank 1
dmm asked on 22 May 2007, 01:32 PM
Hello,

I downloaded the SP1 for WinForm controls and was under the belief that the Treeview would support making a tree node visible at runtime. I can select the node, programmatically, but want to make it visible within the tree, for example EnsureFocus on the tree node?

So if the node is at the bottom, which the user cannot see I want the node to be in focus. Something like Treeview.Nodes[name].EnsureFocus

Is this possible and if so how?

Thanks

10 Answers, 1 is accepted

Sort by
0
Boyko Markov
Telerik team
answered on 22 May 2007, 04:32 PM
Thank you for your interest in our controls, Dave.

Indeed, this feature is supported. You could use the BringIntoView method of RadTreeView to bring a node into the visible area of the tree. The method accepts as parameter an instance of RadTreeNode and scrolls until that node becomes visible.

I hope this helps. Let me know if I can be of further assistance.


Sincerely yours,
Ray
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
dmm
Top achievements
Rank 1
answered on 24 May 2007, 06:19 PM
Hello,

Hope you enjoy/enjoyed the Bulgarian holiday!

After the celebrations......

Please could you gve me some sample code for the BringIntoView as I have tried it and cannot get it to work. I am not too sure if I need to set some properties in the Treeview itself our how to reference the node directly.

I can select the node I required, I can see it selected if I scroll down, but using the BringIntoView method, still does not scroll it into view?

Any help on this would be really appreciated.

Many Regards
David

0
Boyko Markov
Telerik team
answered on 28 May 2007, 08:25 AM
Thank you, Dave, we are all rested now and back to work!

I've found a bug related to the BringIntoView method and it seems that it works only if you have the AllowArbitaryItemHeight property of RadTreeView set to true. I'm sorry for that inconvenience. That bug is going to be fixed in the next upcoming Service Pack release of RadControls for WinForms.

Here is a sample code demonstrating how to use the BringIntoView method:
 
this.radTreeView1.AllowArbitaryItemHeight = true
this.radTreeView1.BringIntoView(this.radTreeView1.Nodes[index]); 
 

Index is an integer-based value which represent  the index of a node in the collection. 

If you need further assistance please feel free to write back.
 

Regards,
Ray
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
dmm
Top achievements
Rank 1
answered on 31 May 2007, 12:21 PM
Hello Ray,

Thanks for getting back to me.

That worked great, although the node is at the very bottom of the treeview, still just out of view but it is correct.

Is there are way to simulate a scroll down by a couple of clicks as this would make it perfect, if its not possible I will see if I can hook to the control and do it directly some how.

Anyway,  thanks that helped alot.

One other question, I have a RadTooolStrip with a ComboBox control.

This is used to quickly find the nodes within the tree structure as discussed previously, however, when a selection is made I want the focus to move away from this control.

So, when an item is selected from the RadToolStripItem (combobox) I wish it to set the focus to another control such as a textbox.select().

The probem I have is that the combobox keeps focus even after doing a textbox.select() or textbox.focus().

Do you or your technical guys have any idea on how to achieve this.

Many Regards
David
0
dmm
Top achievements
Rank 1
answered on 31 May 2007, 12:57 PM
Hello Ray,

Just to follow up on this scroll of the treeview, I though I should be able to use SendMessage API to accomplish this, but it does not seem to work with the control handle?

E.g something like this? Am I going in th right direction with the SendMessage API?

SendMessage(this.NavigatorTreeView.Handle, WM_VSCROLL, (IntPtr)SB_LINEDOWN, IntPtr.Zero);

Many Regards
David Mavin

0
dmm
Top achievements
Rank 1
answered on 01 Jun 2007, 10:50 AM
Hello,

I tried to use the SendMessage API to scroll the tree but have had no success. The following code works fine when testing with a multiline textbox as follows, but it will not work with the treeview? Is the handle correct when using the treeview or am I missing something.

using System.Runtime.InteropServices;

private const int WM_SCROLL = 276; // Horizontal scroll

private const int WM_VSCROLL = 277; // Vertical scroll

private const int SB_LINEUP = 0; // Scrolls one line up

private const int SB_LINELEFT = 0;// Scrolls one cell left

private const int SB_LINEDOWN = 1; // Scrolls one line down

private const int SB_LINERIGHT = 1;// Scrolls one cell right

private const int SB_PAGEUP = 2; // Scrolls one page up

private const int SB_PAGELEFT = 2;// Scrolls one page left

private const int SB_PAGEDOWN = 3; // Scrolls one page down

private const int SB_PAGERIGTH = 3; // Scrolls one page right

private const int SB_PAGETOP = 6; // Scrolls to the upper left

private const int SB_LEFT = 6; // Scrolls to the left

private const int SB_PAGEBOTTOM = 7; // Scrolls to the upper right

private const int SB_RIGHT = 7; // Scrolls to the right

private const int SB_ENDSCROLL = 8; // Ends scroll


[DllImport("user32.dll", CharSet = CharSet.Auto)]

private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);



Finally I send the command via a button to test as follows.

SendMessage(this.textBox1.Handle, WM_VSCROLL, (IntPtr)SB_LINEDOWN, IntPtr.Zero);

This works fine but doing the same thing with the Treeview does not, any help on this?

Many Regards
David

0
Boyko Markov
Telerik team
answered on 01 Jun 2007, 12:40 PM
Hi dmm,

You could move the vertical scroll bar using the ScrollBy method of RadTreeView which accepts a delta argument.
We will continue working on making the behavior of the BringIntoView method to be more precise.

As to your second question about RadToolStrip with ComboBox, could you please give me more information on the task you want to accomplish? I was not able to understand whether the textBox is an item of the ToolStripItem''s items collection. If possible, please send me a sample project replicating the issue in a new support ticket. This will help me debug your concrete scenario.

I hope that will help you with the question related to RadTreeView. I will be looking forward to your reply for the second issue.


Regards,
Ray
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
dmm
Top achievements
Rank 1
answered on 01 Jun 2007, 08:43 PM
Hello Ray,

Once again thanks for the excellent support!

I am very close to finishing the project now, with the evaluation, and getting my company to purchase the product very soon.

First, Yes the  ScrollBy method works perfectly with the other suggestions made. If anyone else needs to do this the sequence of events is as follows, as you have suggested.

this.NavigatorTreeView.AllowArbitaryItemHeight = true;
this.NavigatorTreeView.BringIntoView(descriptionTypes);
this.NavigatorTreeView.ScrollBy(-1);

I may have not described my second issue very well so apologies. 

The project is a Outlook add-in component so the code is quite long and I feel sending it will simply confuse.

Its quite simply that I have a form with a RadToolStrip placed on it. This has a ComboBox (RadComboBoxElement ) in it.

I also have a RadTreeView control on the form.

After I select an item in ComboBox I want the focus to move to the TreeView control. However, if I do treeview.Select() after this event the focus does not move, the focus remains on the ComboBox.

I cannot move the focus from the RadComboBoxElement in the RadToolStrip after an item is selected to any other control, in testing, such as a button ot textbox etc. E.g Button.Select(), TextBox1.Select() etc.

Many Regards
David


 

0
Jordan
Telerik team
answered on 02 Jun 2007, 07:58 AM
Hi Dave,

Glad to hear that we've helped.

Now to the focus issue. To focus a button (or any other control) after selecting an item form a RadComboBoxElement in a RadToolStrip, you have to execute your focus code in the PopupClosed handler like:

void radComboBoxElement1_PopupClosed(object sender, RadPopupClosedEventArgs args)  
{  
    this.radButton1.Focus();  


Sincerely yours,
Jordan
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
dmm
Top achievements
Rank 1
answered on 03 Jun 2007, 09:13 AM
Hello,

Thanks that worked great!
As said, thanks for the excellent support.

Many Regards
David
Tags
Treeview
Asked by
dmm
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
dmm
Top achievements
Rank 1
Jordan
Telerik team
Share this question
or