Shape.Tag 속성
선 또는 도형 컨트롤에 대 한 데이터가 들어 있는 개체를 가져오거나 설정 합니다.
네임스페이스: Microsoft.VisualBasic.PowerPacks
어셈블리: Microsoft.VisualBasic.PowerPacks.Vs(Microsoft.VisualBasic.PowerPacks.Vs.dll)
구문
‘선언
<BrowsableAttribute(True)> _
Public Property Tag As Object
[BrowsableAttribute(true)]
public Object Tag { get; set; }
[BrowsableAttribute(true)]
public:
property Object^ Tag {
Object^ get ();
void set (Object^ value);
}
[<BrowsableAttribute(true)>]
member Tag : Object with get, set
function get Tag () : Object
function set Tag (value : Object)
속성 값
형식: System.Object
Object 컨트롤에 연결 된 데이터를 포함 합니다.기본값은 null 참조(Visual Basic의 경우 Nothing)입니다.
설명
Object 클래스에서 파생된 형식은 모두 이 속성에 할당될 수 있습니다.경우는 Tag Windows Forms 디자이너를 통해 속성을 설정할 때는 텍스트에만 할당 될 수 있습니다.
Tag 속성은 대개 컨트롤과 밀접하게 연결된 데이터를 저장하는 데 사용됩니다.예를 들어 네트워크 토폴 리지의 개체를 나타내는 도형 컨트롤이 있는 경우 저장할 수 있는 DataSet 해당 개체에 대 한 정보를 포함의 Tag 속성의 데이터를 신속 하 게 액세스할 수 있도록 합니다.
예제
다음 예제에서는 Tag 속성의 인스턴스를 전달 하는 NodeInfo 클래스에 새 양식.이 예제 사용 해야는 RectangleShape 정의 된 및 networkForm, 라는 두 번째 폼을 가진 폼에 RectangleShape1 이라는 컨트롤의 NodeInfo 클래스를 프로젝트에.
Private Sub Form1_Load() Handles MyBase.Load
' Declare an instance of a NodeInfo class.
Dim MyNode As New NodeInfo
' Assign the instance to the Tag property.
RectangleShape1.Tag = MyNode
End Sub
Private Sub RectangleShape1_Click() Handles RectangleShape1.Click
' Declare an instance of a networkForm form.
Dim networkForm As New Form()
' Assign the Tag property of the RectangleShape to the new form.
' This passes the MyNode instance of the NodeInfo class to the
' form.
networkForm.Tag = RectangleShape1.Tag
' Show the new form.
networkForm.Show()
End Sub
private void Form1_Load(System.Object sender, System.EventArgs e)
{
// Declare an instance of a NodeInfo class.
NodeInfo MyNode = new NodeInfo();
// Assign the instance to the Tag property.
rectangleShape1.Tag = MyNode;
}
private void rectangleShape1_Click(System.Object sender, System.EventArgs e)
{
// Declare an instance of a networkForm form.
Form networkForm = new Form();
// Assign the Tag property of the RectangleShape to the new form.
// This passes the MyNode instance of the NodeInfo class to the
// form.
networkForm.Tag = rectangleShape1.Tag;
// Show the new form.
networkForm.Show();
}
.NET Framework 보안
- 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.
참고 항목
참조
Microsoft.VisualBasic.PowerPacks 네임스페이스
기타 리소스
방법: LineShape 컨트롤로 선 그리기(Visual Studio)
방법: OvalShape 및 RectangleShape 컨트롤을 사용하여 도형 그리기(Visual Studio)