Control.ControlAccessibleObject.Owner 속성
액세스 가능 개체의 소유자를 가져옵니다.
네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)
구문
‘선언
Public ReadOnly Property Owner As Control
‘사용 방법
Dim instance As ControlAccessibleObject
Dim value As Control
value = instance.Owner
public Control Owner { get; }
public:
property Control^ Owner {
Control^ get ();
}
/** @property */
public Control get_Owner ()
public function get Owner () : Control
속성 값
이 Control.ControlAccessibleObject를 소유하는 Control입니다.
예제
다음 코드 예제에서는 CheckBox 클래스에서 파생되는 CheckBox 컨트롤을 만들고 사용할 파생 클래스에 대한 사용자 지정 Control.ControlAccessibleObject를 만듭니다. 파생된 클래스인 MyCheckBox
에는 기본적으로 토글 단추로 나타나도록 Button의 Appearance가 있습니다. 파생된 Control.ControlAccessibleObject 클래스인 MyCheckBoxControlAccessibleObject
는 모양 차이가 고려되도록 세 가지 속성이 재정의됩니다.
Imports System
Imports System.Windows.Forms
Imports Accessibility
Imports System.Drawing
Namespace MyCustomControls
Public Class MyCheckBox
Inherits CheckBox
Public Sub New()
' Make the check box appear like a toggle button.
Me.Appearance = Appearance.Button
' Center the text on the button.
Me.TextAlign = ContentAlignment.MiddleCenter
End Sub
' Create an instance of the AccessibleObject
' defined for the 'MyCheckBox' control
Protected Overrides Function CreateAccessibilityInstance() _
As AccessibleObject
Return New MyCheckBoxAccessibleObject(Me)
End Function
End Class
' Accessible object for use with the 'MyCheckBox' control.
Friend Class MyCheckBoxAccessibleObject
Inherits Control.ControlAccessibleObject
Public Sub New(owner As MyCheckBox)
MyBase.New(owner)
End Sub
Public Overrides ReadOnly Property DefaultAction() As String
Get
' Return the DefaultAction based upon
' the state of the control.
If CType(Owner, MyCheckBox).Checked Then
Return "Toggle button up"
Else
Return "Toggle button down"
End If
End Get
End Property
Public Overrides Property Name() As String
Get
' Return the Text property of the control
' if the AccessibleName is null.
Dim accessibleName As String = Owner.AccessibleName
If Not (accessibleName Is Nothing) Then
Return accessibleName
End If
Return CType(Owner, MyCheckBox).Text
End Get
Set
MyBase.Name = value
End Set
End Property
Public Overrides ReadOnly Property Role() As AccessibleRole
Get
' Since the check box appears like a button,
' make the Role the same as a button.
Return AccessibleRole.PushButton
End Get
End Property
End Class
End Namespace
using System;
using System.Windows.Forms;
using Accessibility;
using System.Drawing;
namespace MyCustomControls
{
public class MyCheckBox : CheckBox
{
public MyCheckBox()
{
// Make the check box appear like a toggle button.
this.Appearance = Appearance.Button;
// Center the text on the button.
this.TextAlign = ContentAlignment.MiddleCenter;
// Set the AccessibleDescription text.
this.AccessibleDescription = "A toggle style button.";
}
// Create an instance of the AccessibleObject
// defined for the 'MyCheckBox' control
protected override AccessibleObject CreateAccessibilityInstance()
{
return new MyCheckBoxAccessibleObject(this);
}
}
// Accessible object for use with the 'MyCheckBox' control.
internal class MyCheckBoxAccessibleObject : Control.ControlAccessibleObject
{
public MyCheckBoxAccessibleObject(MyCheckBox owner) : base(owner)
{
}
public override string DefaultAction
{
get
{
// Return the DefaultAction based upon
// the state of the control.
if( ((MyCheckBox)Owner).Checked )
{
return "Toggle button up";
}
else
{
return "Toggle button down";
}
}
}
public override string Name
{
get
{
// Return the Text property of the control
// if the AccessibleName is null.
string name = Owner.AccessibleName;
if (name != null)
{
return name;
}
return ((MyCheckBox)Owner).Text;
}
set
{
base.Name = value;
}
}
public override AccessibleRole Role
{
get
{
// Since the check box appears like a button,
// make the Role the same as a button.
return AccessibleRole.PushButton;
}
}
}
}
#using <Accessibility.dll>
#using <System.Drawing.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Windows::Forms;
using namespace System::Drawing;
namespace MyCustomControls
{
public ref class MyCheckBox: public CheckBox
{
public:
MyCheckBox()
{
// Make the check box appear like a toggle button.
this->Appearance = ::Appearance::Button;
// Center the text on the button.
this->TextAlign = ContentAlignment::MiddleCenter;
// Set the AccessibleDescription text.
this->AccessibleDescription = "A toggle style button.";
}
protected:
// Create an instance of the AccessibleObject
// defined for the 'MyCheckBox' control
virtual AccessibleObject^ CreateAccessibilityInstance() override;
};
// Accessible Object* for use with the 'MyCheckBox' control.
private ref class MyCheckBoxAccessibleObject: public Control::ControlAccessibleObject
{
public:
MyCheckBoxAccessibleObject( MyCheckBox^ owner )
: ControlAccessibleObject( owner )
{}
property String^ DefaultAction
{
virtual String^ get() override
{
// Return the DefaultAction based upon
// the state of the control.
if ( (dynamic_cast<MyCheckBox^>(Owner))->Checked )
{
return "Toggle button up";
}
else
{
return "Toggle button down";
}
}
}
property String^ Name
{
virtual String^ get() override
{
// Return the Text property of the control
// if the AccessibleName is 0.
String^ name = Owner->AccessibleName;
if ( name != nullptr )
{
return name;
}
return (dynamic_cast<MyCheckBox^>(Owner))->Text;
}
virtual void set( String^ value ) override
{
ControlAccessibleObject::Name = value;
}
}
property AccessibleRole Role
{
virtual AccessibleRole get() override
{
// Since the check box appears like a button,
// make the Role the same as a button.
return AccessibleRole::PushButton;
}
}
};
AccessibleObject^ MyCheckBox::CreateAccessibilityInstance()
{
return gcnew MyCheckBoxAccessibleObject( this );
}
}
package MyCustomControls;
import System.*;
import System.Windows.Forms.*;
import Accessibility.*;
import System.Drawing.*;
public class MyCheckBox extends CheckBox
{
public MyCheckBox()
{
// Make the check box appear like a toggle button.
this.set_Appearance(get_Appearance().Button);
// Center the text on the button.
this.set_TextAlign(ContentAlignment.MiddleCenter);
// Set the AccessibleDescription text.
this.set_AccessibleDescription("A toggle style button.");
} //MyCheckBox
// Create an instance of the AccessibleObject
// defined for the 'MyCheckBox' control
protected AccessibleObject CreateAccessibilityInstance()
{
return new MyCheckBoxAccessibleObject(this);
} //CreateAccessibilityInstance
} //MyCheckBox
// Accessible object for use with the 'MyCheckBox' control.
class MyCheckBoxAccessibleObject extends Control.ControlAccessibleObject
{
public MyCheckBoxAccessibleObject(MyCheckBox owner)
{
super(owner);
} //MyCheckBoxAccessibleObject
/** @property
*/
public String get_DefaultAction()
{
// Return the DefaultAction based upon
// the state of the control.
if (((MyCheckBox)get_Owner()).get_Checked()) {
return "Toggle button up";
}
else {
return "Toggle button down";
}
} //get_DefaultAction
/** @property
*/
public String get_Name()
{
// Return the Text property of the control
// if the AccessibleName is null.
String name = get_Owner().get_AccessibleName();
if (name != null) {
return name;
}
return ((MyCheckBox)get_Owner()).get_Text();
} //get_Name
/** @property
*/
public void set_Name(String value)
{
super.set_Name(value);
} //set_Name
/** @property
*/
public AccessibleRole get_Role()
{
// Since the check box appears like a button,
// make the Role the same as a button.
return AccessibleRole.PushButton;
} //get_Role
} //MyCheckBoxAccessibleObject
플랫폼
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
2.0, 1.1, 1.0에서 지원
참고 항목
참조
Control.ControlAccessibleObject 클래스
Control.ControlAccessibleObject 멤버
System.Windows.Forms 네임스페이스
AccessibleObject.Parent 속성
Control.ControlAccessibleObject