type casting open application members
I'm using that looks like TestComplete's open application capability to get pointers to the panel and .NET Form (written in C#) that I want.
I could use WinFormsObject(), but let's say that I found a specific element by searching through comparing properties (tag ID or something) rather than by name. I now have a pointer to a .NET object that does not support calls to WinFormsObject(). What I'd like to do is retrieve some data, but at some point, the references are of type object and this seems to prevent me from accessing their data field.
So.. I've got a line that looks like this
This reports in error in TestComplete. I know that the the object pointed to by panelData.Controls.Item(0).Controls.Item(0) has a member called _myListView. I know that I can access it via
I CAN'T seem to access it via panelData.Controls.Item(0).Controls.Item(0)._myLis tView;
My best guess so far is that panelData.Controls.Item(0).Controls.Item(0) is of type object and NOT of the type of form that I have. How can I perform the type cast or get around this problem another way?
Re: type casting open application members
When you obtain an object via native properties and methods of another object, you get a native .NET object, not a wrapper created by TestComplete. As only wrapper objects have the WinFormsObject method, you cannot call it in such a case.
To "convert" a native object to a wrapper object, you can use the Find method. For example:
<font class="small">Code:</font><hr /><pre>
var parent = Sys.Process("MyApp").WinFormsObject("SomeObject");
var myObj = parent.Controls.Item(0).Controls.Item(0)
myObj = parent.Find("Handle", myObj.Handle.ToString().OleValue, 5)
Please see the "Find Method" help topic for more information on using this method.