Hi,
I want a combo box which would behave like the combox box present on FileOpenDialog. This combo box display its contains in tree view manner in its drop down list. If there is any special control in infragistic, please let me know. If not, how should i proceed?
Thanks in adavance,
Ujwal Salunkhe
Hi Ujwal,
There's no control with a dropdown tree built-in. But you can make your own and it's pretty easy. Place an UltraTextEditor control on a form and use the ButtonsRight collection to add a DropDownEditorButton. Set this button's Control property to an UltraWinTree control.
You now have a dropdown control with a tree on it. And the best part is that this control is an editor. So you could use it as the EditorControl of a grid cell, for example.
Hi Mike,
Thanks for the help. I will try it and let you know.
Thanks,
Ujwal
I was using the treeview_AfterSelect event to get the selected node into the ultratext editor. So was not able to get the DropDownEditorButton class' CloseUp method.Anyhow i solved the problem by calling the treeview_DoubleClick to close the tree and make the selected node available as text in the ultratext editor.
Thanks Brian,
Sorry, I am still not following why you were "not able to get the DropDownEditorButton class' CloseUp method", but hopefully the following code sample will clarify the correct approach:
using Infragistics.Win;using Infragistics.Win.UltraWinEditors;using Infragistics.Win.UltraWinTree;
private void button1_Click(object sender, EventArgs e){ // Create a DropDownEditorButton DropDownEditorButton dropDownButton = new DropDownEditorButton( "dropDownButton" );
// Create an UltraTree, set its size, add some nodes UltraTree treeControl = new UltraTree(); treeControl.Size = new Size( this.ultraTextEditor.Width, 200 ); for ( int i = 0; i < 100; i ++ ) { treeControl.Nodes.Add( null, "Node" + i.ToString() ); } // Assign the UltraTree to the DropDownEditorButton's Control property dropDownButton.Control = treeControl;
// Add the DropDownEditorButton to the UltraTextEditor's ButtonsRight collection this.ultraTextEditor.ButtonsRight.Add( dropDownButton );
// Assign a reference to the UltraTextEditor to the UltraTree's Tag property. treeControl.Tag = this.ultraTextEditor;
// Handle the UltraTree's AfterSelect event treeControl.AfterSelect += new AfterNodeSelectEventHandler(treeControl_AfterSelect);}
private void treeControl_AfterSelect(object sender, SelectEventArgs e){ UltraTree tree = sender as UltraTree; if ( e.NewSelections.Count == 1 ) { UltraTextEditor ute = tree.Tag as UltraTextEditor; if ( ute != null && ute.ButtonsRight.Exists("dropDownButton") ) { // Assign the selected node's text to the UltraTextEditor's Text property ute.Text = e.NewSelections[0].Text; DropDownEditorButton dropDownButton = ute.ButtonsRight["dropDownButton"] as DropDownEditorButton;
// Close the dropdown dropDownButton.CloseUp(); } }}
Brain, i did this using the designer and not at the runtime. That could be the reason i didn't get the event.
I solved the problem by adding a double-click event and in the Tree_AfterSelect event i would call double-Click event so that it closes.
Now, after selecting a value from tree, the TextEditor is set to the that value.Next time the user clicks on the dropdowneditor button, treeview is shown but the node is not selected by default.
Eg: User selects the last leaf node and comes back to the treeview. I have a scroll bar (vertical) and hence it shows from the top, user is not able to see the treeview with the node selected.
Instead, the tree view should be displayed with the value in the texteditor as the selected node. Is that possible?
Thanks.,
Handle the DropDownEditorButton's BeforeDropDown event, and match the text in the UltraTextEditor to a node. If the node keys are the same as the text, you can use UltraTree's GetNodeByKey method to find the node. Once you have a reference to the node, you can set its Selected property to true.
I tried it, but in vain. Below is the code snippet that i wrote inside BeforeEditorButtonDropDown event..,
{
}
Anything wrong here? The cursor was in the UltraFieldTextEditor., may be is that a reason?
Thanks,.
UltraWinTree hides the selection by default when it does not have focus. The Inbox tree control does the same thing.
Try setting HideSelection on the tree to false and see if that helps.