Forum Discussion
Dmitry_Nikolaev
13 years agoStaff
Hi Prashant,
Items of an UltraListBar control are ownerdrawn and do not have separate UI objects that can be used to represent them in the object hierarchy. However, it is possible to work with them using the native methods and properties of the UltraListBar control which are available due to TestComplete's Open Applications feature. Here is a sample demonstrating how you can work with this control in script:
function Test()
{
// The script works with the '<Infragistics>\NetAdvantage for .NET <version>\Samples\Win\WinListBar\CS\
// Appearances CS\bin\Appearances.exe' sample application
var groupName = "Group Two";
var itemName = "Item Two";
var ultraListBar = Sys.Process("Appearances").WinFormsObject("Form1").WinFormsObject("ultraListBar1");
var group = FindGroupByName(ultraListBar, groupName);
if (null == group) {
Log.Error("Group was not found");
return;
}
var item = FindItemByName(group, itemName);
if (item == null) {
Log.Error("Item was not found");
return;
}
// Click the item
group.Selected = true;
item.EnsureVisible();
var rect = group.UIElement.ClipRect;
ultraListBar.Focus();
ultraListBar.Click(rect.Left + ocrObj.FoundLeft + 5, rect.Top + ocrObj.FoundTop + 5);
}
function FindGroupByName(ultraListBar, groupName)
{
for(var i = 0; i < ultraListBar.Groups.Count; i++)
if (ultraListBar.Groups.Item(i).Text == groupName)
return ultraListBar.Groups.Item(i);
return null;
}
function FindItemByName(group, itemName)
{
var i;
for(i = 0; i < group.Items.Count; i++)
if (group.Items.Item(i).Text == itemName)
return group.Items.Item(i);
return null;
}
BTW, you can vote for your control in TestComplete Feature Survey.
Related Content
- 6 years ago
Recent Discussions
- 5 hours ago