Table of Contents

Class Control

Namespace
Ranorex
Assembly
Ranorex.Plugin.WinForms.dll

Capability of a .NET Windows Forms control.

public class Control : Adapter, IAdapter
Inheritance
Control
Implements
Inherited Members

Constructors

Control()

Creates a new Control adapter instance. This constructor is used internally by the Ranorex Core Framework for performance issues!

protected Control()

Control(Element)

Creates a new Control adapter instance.

public Control(Element element)

Parameters

element Element

The element to create the adapter for.

Exceptions

NullReferenceException

If element is null.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.

Properties

this[string]

Gets or sets the (serializable) value of the specified control property.

public object this[string name] { get; set; }

Parameters

name string

The name of the property.

Property Value

object

The value of the property.

Remarks

The getter of this property calls the GetPropertyValue(string) method, the setter calls the SetPropertyValue(string, object) method.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

Name

The name of the Windows Forms control.

[OriginalDisplayName("ControlName")]
public virtual string Name { get; }

Property Value

string

RequiredCapabilities

Capabilities required by the adapter implementation.

protected override string[] RequiredCapabilities { get; }

Property Value

string[]

Text

The text of the Windows Forms control.

[OriginalDisplayName("ControlText")]
public virtual string Text { get; set; }

Property Value

string

Exceptions

SetAttributeFailedException

Thrown if setting the attribute value failed.

Type

The full type name of the Windows Forms control.

[OriginalDisplayName("ControlType")]
public virtual string Type { get; }

Property Value

string

TypeName

The (short) type name of the Windows Forms control.

[OriginalDisplayName("ControlTypeName")]
public virtual string TypeName { get; }

Property Value

string

Methods

FromElement(Element)

Converts an Element to an instance of this class.

public static Control FromElement(Element element)

Parameters

element Element

The element to convert.

Returns

Control

The Control.

Exceptions

ArgumentNullException

If element is null.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.

FromPath(string)

Converts a string to an instance of this class by searching the root.

public static Control FromPath(string path)

Parameters

path string

The search path.

Returns

Control

The Control.

Remarks

The DefaultSearchTimeout is used to search for the specified path.

Exceptions

ArgumentNullException

If path is null.

RxPathException

If the specified path is not valid.

ElementNotFoundException

If no element is found.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.

GetPropertyValue(BindingFlags, string)

Gets the (serializable) value of the specified control property.

public virtual object GetPropertyValue(BindingFlags flags, string name)

Parameters

flags BindingFlags

A combination of flags that further specify which property to get.

name string

The name of the property.

Returns

object

The value of the property.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

GetPropertyValue(string)

Gets the (serializable) value of the specified control property.

public virtual object GetPropertyValue(string name)

Parameters

name string

The name of the property.

Returns

object

The value of the property.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

GetPropertyValue<T>(BindingFlags, string)

Gets the (serializable) value of the specified control property.

public T GetPropertyValue<T>(BindingFlags flags, string name)

Parameters

flags BindingFlags

A combination of flags that further specify which property to get.

name string

The name of the property.

Returns

T

The value of the named property or the default value of the specified type if the returned value is null and the specified type is a value type.

Type Parameters

T

The type of the property to get the value from.

Exceptions

InvalidCastException

If the returned value cannot be casted to the specified type.

ActionFailedException

Thrown if invoking the action failed.

GetPropertyValue<T>(string)

Gets the (serializable) value of the specified control property.

public T GetPropertyValue<T>(string name)

Parameters

name string

The name of the property.

Returns

T

The value of the named property or the default value of the specified type if the returned value is null and the specified type is a value type.

Type Parameters

T

The type of the property to get the value from.

Exceptions

InvalidCastException

If the returned value cannot be casted to the specified type.

ActionFailedException

Thrown if invoking the action failed.

InvokeMethod(BindingFlags, string, object[])

Invokes the specified method on the control. All parameters and the return value need to be serializable.

public object InvokeMethod(BindingFlags flags, string name, object[] args)

Parameters

flags BindingFlags

A combination of flags that further specify which method to invoke.

name string

The name of the method to invoke.

args object[]

The (serializable) values passed as parameters to the method.

Returns

object

The (serializable) return value of the invoked method.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

InvokeMethod(BindingFlags, string, object[], Duration)

Invokes the specified method on the control. All parameters and the return value need to be serializable.

public virtual object InvokeMethod(BindingFlags flags, string name, object[] args, Duration timeout)

Parameters

flags BindingFlags

A combination of flags that further specify which method to invoke.

name string

The name of the method to invoke.

args object[]

The (serializable) values passed as parameters to the method.

timeout Duration

The timeout for this action. The action will return after the timeout even if the method has not yet finished executing.

Returns

object

The (serializable) return value of the invoked method.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

InvokeMethod(string)

Invokes the specified method on the control.

public object InvokeMethod(string name)

Parameters

name string

The name of the method to invoke.

Returns

object

The (serializable) return value of the invoked method.

Remarks

Use this method to invoke public instance methods without arguments on a control.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

InvokeMethod(string, object[])

Invokes the specified method on the control. All parameters need to be serializable.

public object InvokeMethod(string name, object[] args)

Parameters

name string

The name of the method to invoke.

args object[]

The (serializable) values passed as parameters to the method.

Returns

object

The (serializable) return value of the invoked method.

Remarks

Use this method to invoke public instance methods on a control.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

InvokeRemotely(RemotelyInvokedDelegate)

Invokes the delegate remotely at the control. All parameters and the return value need to be serializable.

public object InvokeRemotely(RemotelyInvokedDelegate deleg)

Parameters

deleg RemotelyInvokedDelegate

The delegate to invoke at the remote control.

Returns

object

The (serializable) return value of the remotely invoked delegate.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

InvokeRemotely(RemotelyInvokedDelegate, object)

Invokes the delegate remotely at the control. All parameters and the return value need to be serializable.

public object InvokeRemotely(RemotelyInvokedDelegate deleg, object inputData)

Parameters

deleg RemotelyInvokedDelegate

The delegate to invoke at the remote control.

inputData object

The (serializable) input data passed to the delegate at the remote control.

Returns

object

The (serializable) return value of the remotely invoked delegate.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

InvokeRemotely(RemotelyInvokedDelegate, object, Duration)

Invokes the delegate remotely at the control. All parameters and the return value need to be serializable.

public virtual object InvokeRemotely(RemotelyInvokedDelegate deleg, object inputData, Duration timeout)

Parameters

deleg RemotelyInvokedDelegate

The delegate to invoke at the remote control.

inputData object

The (serializable) input data passed to the delegate at the remote control.

timeout Duration

The timeout for this action. The action will return after the timeout even if the delegate has not yet finished executing.

Returns

object

The (serializable) return value of the remotely invoked delegate.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

SetPropertyValue(BindingFlags, string, object)

Sets the (serializable) value of the specified control property.

public virtual void SetPropertyValue(BindingFlags flags, string name, object value)

Parameters

flags BindingFlags

A combination of flags that further specify which property to set.

name string

The name of the property.

value object

The value (must be serializable) to set the property to.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

SetPropertyValue(string, object)

Sets the (serializable) value of the specified control property.

public virtual void SetPropertyValue(string name, object value)

Parameters

name string

The name of the property.

value object

The value (must be serializable) to set the property to.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

Operators

implicit operator Control(Element)

Implicitly converts an Element to an instance of this class.

public static implicit operator Control(Element element)

Parameters

element Element

The element to convert.

Returns

Control

The Control.

Exceptions

ArgumentNullException

If element is null.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.

implicit operator Control(string)

Implicitly converts a string to an instance of this class by searching the root.

public static implicit operator Control(string path)

Parameters

path string

The search path.

Returns

Control

The Control.

Remarks

The DefaultSearchTimeout is used to search for the specified path.

Exceptions

ArgumentNullException

If path is null.

RxPathException

If the specified path is not valid.

ElementNotFoundException

If no element is found.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.