Hi
I am having issues with UltraUiaComboBox. Simply i want to select item from dropdown and i do this:
Combobox.SelectedItem = "Item"... After this I see that it clicks on dropdown icon and it is moving from top to bottom of dropdown list and at the end if fails.
What is going on ?
i tried with http://msdn.microsoft.com/en-us/library/system.windows.automation.selectionitempattern.select.aspx
solution and it seams that everything is going to be ok but when it tries to do .select() ... Exception happens.
if this is not possible to do, is there any other way to get all items except combobox.items.
I made workaround to select dropdown item but this combobox.items method is taking long time to get all the items.
I am trying to get all items using NativeElements ..
Thanks to good friend Chris :) who pointed me in right direction i made workaround that looks like this:
UltraUiaComboBox uuComboBox = ( UltraUiaComboBox )control;
if ( uuComboBox.SelectedItem == providedValue) break;
AutomationElement containerAutomationElement = uuComboBox.NativeElement as AutomationElement; AutomationElementCollection elements = containerAutomationElement.FindAll( TreeScope.Children, Condition.TrueCondition ); uuComboBox.SetFocus(); Keyboard.SendKeys( "{HOME}" );
for ( int i = 0; i < elements.Count; i++ ) { try { string name = elements[ i ].Current.Name; if ( String.IsNullOrEmpty( name ) || name != providedValue) Keyboard.SendKeys( "{DOWN}" ); else break; } catch { } }
I know that this is not best solution but it is only one that works for me now. If someone finds other solution please reply on this thread.
Hi Hristo
Thanks for explanation and attachment. I appreciate it.
Yes it is true, currently we are using 12.2 version and it will stay like that for a while.
so i will stick to my solution for now.
thanks
Almir
Hello Amir,
Thank you for your feedback.
Thank you for using Infragistics Components.
Hey Almir,
The EditableItem property should work in 12.2. I've tested it to verify. Another solution would be to use the ValuePattern to set the value on the editor's AutomationElement.
UltraUiaComboBox combo = this.UIForm1Window.UIUltraComboEditor1Window.UIUltraComboEditor1ComboBox;
// Approach #1 combo.EditableItem = "Item1";
// Approach #2 AutomationElement comboAutomationElement = combo.NativeElement as AutomationElement; ValuePattern valuePattern = comboAutomationElement.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; if (valuePattern != null) valuePattern.SetValue("ValueListItem2"); // make sure this is the DataValue, not the DisplayText of the ValueListItem you want to select
I hope this helps.
Chris
Hi Chris
First approach is not working, really do not know why.
i will try second and let you know.
Thanks
Hello,
We are waiting for your feedback.
Works like a charm :D THANKS A LOT.
BestAlmir
Thanks Chris
I will try this code, and I will let you know is it working for me. For now I added some workaround that is working, but this code would be much more safe.
Best
Try the following code:
public void AssertMethod1() { #region Variable Declarations UltraUiaComboBox uIUltraComboEditor1ComboBox = this.UIForm1Window.UIUltraComboEditor1Window.UIUltraComboEditor1ComboBox; #endregion
AutomationElement comboElement = uIUltraComboEditor1ComboBox.NativeElement as AutomationElement; if (comboElement == null) Assert.Fail("Could not locate the AutomationElement");
ItemContainerPattern containerPattern = comboElement.GetCurrentPattern(ItemContainerPattern.Pattern) as ItemContainerPattern; if (containerPattern == null) Assert.Fail("Could not locate the ItemContainerPattern on the AutomationElement");
AutomationElement selectedElement = containerPattern.FindItemByProperty(null, SelectionItemPatternIdentifiers.IsSelectedProperty, true); if (selectedElement == null) Assert.Fail("No Selected AutomationElement");
// change this line line to match your selected text
Assert.AreEqual("DisplayTextOfSelection", selectedElement.Current.Name); }
At this point, I'd be nervous about us changing the SelectedItem to be the display text of selected item, as it would most likely break existing tests that are expecting it to return the underlying value.
I am back with questions :)
Could you please help me with this?
I have UltraUiaCombobox with few items. I want to do assert on SelectedItem and when I try that it fails because for SelectedItem it actually selects Value property instead of Text.
And I am asserting by Text value (value that is visible to user).
Its very strange that the options we provided do not work for you. There must be something within the design of your application that we're not aware of. At least you have a workaround that meets your needs. Let us know if you have any other questions.
Chris.