How to cast custom controls as DevExpressXtraGrid controls
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to cast custom controls as DevExpressXtraGrid controls
How to cast custom controls as DevExpressXtraGrid controls?
I try to write the following code:
IDriver driver = new LocalDriver();
IWindow dxGridControl = driver.Find<IProcess>(new ProcessPattern()
{
ProcessName = "WT-ToolExport"
}).Find<ITopLevelWindow>(new WinFormsPattern()
{
WinFormsControlName = "DXSearchForm"
}).Find<IWindow>(new WinFormsPattern()
{
WinFormsControlName = "datagridBottomLayoutControl"
}).Find<IWindow>(new WinFormsPattern()
{
WinFormsControlName = "datagridPanelControl"
}).Find<IWindow>(new WinFormsPattern()
{
WinFormsControlName = "gridControl"
});
long CountValue = dxGridControl.GetProperty<long>("DevExpress_XtraEditors_INavigatableControl_RecordCount"); //this returns correct value
var XtraGrid = dxGridControl.Cast<IDevExpressXtraGrid>();
var rowcount = XtraGrid.wRowCount; // I see error
I see wRowCount property for this control in TestComplete :
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You might find using object mapping to be a better approach - you can map a custom object as the type of object you want to interact with.
Additionally, the object tree you're inspecting in TestComplete is a UI Automation -based object tree, while the object tree in the TestLeft Object Spy pictured above is pure WinForms. You may get results more akin to what you're looking for if you use the UIAPattern search pattern, e.g.
IWindow dxGridControl = driver.Find < IProcess > (new ProcessPattern() {
ProcessName = "WT-ToolExport"}).Find < ITopLevelWindow > (new UIAPattern() {
ObjectIdentifier = "DXSearchForm"}).Find < IWindow > (new UIAPattern() {
ObjectIdentifier = "datagridBottomLayoutControl"}).Find < IWindow > (new UIAPattern() {
ObjectIdentifier = "datagridPanelControl"}).Find < IWindow > (new UIAPattern() {
ObjectIdentifier = "gridControl"});
...or similar.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi dermotcanniffe,
Thank you for the answer, but I found a more correct way to solve my problem:
var Driver = new LocalDriver();
var className = "DXSearch.DxGridView.DxGridControl";
// Get the Developer Express Controls Controls category
var DExpressControls = Driver.Options.ObjectMapping["Developer Express Controls"];
// Get the WinForms category
var winFormsControls = DExpressControls["WinForms"];
// Get the list of classes mapped to the XtraGrid control
var XtraGrid = winFormsControls["XtraGrid"];
// Map a custom class to the XtraGrid control
XtraGrid.AddClassName(className);
