I have a DropDownList combo box loaded with 10 items. I have assigned this to teh WinTree.Override.EditorControl. Everything work fine and Editor control shows properly. However, when an item is selected in the combo box, events such as ValueChanged, SelectionChanged do not fire. The problem is that I want to do different things based on the SelectionIndex. However, it is always 0.
Something worng with my question or nobody knows the answer? :-)
When you assign a value to the EditorControl property, you are telling the UltraTree where to get its embeddable editor from. Using that embedded editor within the UltraTree will not cause the control's events to fire. The following code sample demonstrates how to handle the EditorWithCombo-specific events (in this example, SelectionChanged) that are raised by the embedded editor:
using Infragistics.Win;using Infragistics.Win.UltraWinEditors;using Infragistics.Win.UltraWinTree;
public partial class Form1 : Form{ private EditorWithCombo editor = null;
public Form1() { InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e) { // Add some nodes this.tree.Nodes.Add( "Node 1" ); this.tree.Nodes.Add( "Node 2" ); this.tree.Nodes.Add( "Node 3" );
// Add some items this.comboEditor.Items.Add( "Item 1" ); this.comboEditor.Items.Add( "Item 2" ); this.comboEditor.Items.Add( "Item 3" );
// Enabled editing, using an EditorWithCombo provided by the UltraComboEditor this.tree.Override.LabelEdit = DefaultableBoolean.True; this.tree.Override.UseEditor = Infragistics.Win.DefaultableBoolean.True; this.tree.Override.EditorControl = this.comboEditor;
// Hook the UltraTree's AfterActivate event this.tree.AfterActivate += new AfterNodeChangedEventHandler(this.tree_AfterActivate);
}
// Handles the UltraTree's AfterActivate event, for the purpose // of hooking the SelectionChanged event of the EditorWithCombo // associated with the ActiveNode. private void tree_AfterActivate(object sender, NodeEventArgs e) { UltraTreeNode node = e.TreeNode; if ( node == null ) return;
// If the editor hasn't changed since the last time we did this, // return since we are already listening to the right editor's event. EditorWithCombo editor = node.EditorResolved as EditorWithCombo; if ( this.editor == editor ) return;
// If we have a non-null editor reference, unhook its SelectionChanged event if ( this.editor != null ) { this.HookSelectionChanged( this.editor, false ); this.editor = null; }
// Set our reference this.editor = editor;
// Hook the event on the new editor if ( this.editor != null ) this.HookSelectionChanged( this.editor, true ); }
// Handles the EditorWithCombo's SelectionChanged event. private void editor_SelectionChanged(object sender, EventArgs e) { EditorWithCombo editor = sender as EditorWithCombo; object value = editor.Value; }
// Hooks/unhooks the EditorWithCombo's SelectionChanged event. private void HookSelectionChanged( EditorWithCombo editor, bool hook ) { if ( hook ) editor.SelectionChanged += new EventHandler(this.editor_SelectionChanged); else editor.SelectionChanged -= new EventHandler(this.editor_SelectionChanged); }
protected override void Dispose(bool disposing) { if ( disposing ) { if ( this.components != null ) this.components.Dispose();
// If we have a non-null editor reference, unhook its SelectionChanged event if ( this.editor != null ) { this.HookSelectionChanged( this.editor, false ); this.editor = null; } }
base.Dispose(disposing); }
Thank you. My mistake.
I'm not sure I followed this, but the only way to get checkboxes to appear next to the items in UltraComboEditor's dropdown is using a draw filter or creation filter. The first hack that comes to mind is to assign an image to each item, then use the IUIElementCreationFilter interface to pull the image out, and replace it with a CheckBoxUIElement. The problem is that it will not respond to user interaction, since clicking on it will cause the dropdown to close. If this is not a concern, i.e., the checkbox is read-only anyway, you might also be able to show an image of a checkbox (have two images, one for each check state, assigning them based on what the item's "CheckState" is). If none of this is helpful, please repost with clarification and we can try to help.
This looks like you're trying to create a multi-select dropdown.
Although our Windows Forms controls don't currently include a multi-select dropdown, you can use our Windows Forms controls to get the same functionality. The following article from our online Knowledge Base provides more details; although the article is aimed at WinGrid, you can use this same approach in WinTree:HOWTO: Creating a Multi-Select Dropdown Combo for the WinGrid