Ask a Question

How to cast custom controls as DevExpressXtraGrid controls

AndreyP
New Contributor

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

 

AndreyP_0-1681461838197.png

AndreyP_2-1681462235008.png

 

I see wRowCount property for this control in TestComplete :

 

AndreyP_0-1681462189262.png

 

 

 

2 REPLIES 2
dermotcanniffe
SmartBear Alumni (Retired)

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. 


 

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);

 

cancel
Showing results for 
Search instead for 
Did you mean: