ListViewItem.Text 속성

정의

항목 텍스트를 가져오거나 설정합니다.

public:
 property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
public string Text { get; set; }
member this.Text : string with get, set
Public Property Text As String

속성 값

항목에 대해 표시할 텍스트입니다. 이 텍스트는 259자를 초과할 수 없습니다.

예제

다음 코드 예제를 초기화 하는 방법을 보여 줍니다.는 ListViewItemText 속성을 설정 Tag 합니다. 이 예제를 실행하려면 라는 가 포함된 ListView 폼에 다음 코드를 배치하고 폼의 생성자 또는 Load 이벤트 처리 메서드에서 를 호출 InitializeListViewItemsListView1합니다.

private:
   void InitializeListViewItems()
   {
      ListView1->View = View::List;
      array<System::Windows::Forms::Cursor^>^favoriteCursors = {Cursors::Help,Cursors::Hand,Cursors::No,Cursors::Cross};
      
      // Populate the ListView control with the array of Cursors.
      System::Collections::IEnumerator^ myEnum = favoriteCursors->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         System::Windows::Forms::Cursor^ aCursor = safe_cast<System::Windows::Forms::Cursor^>(myEnum->Current);
         
         // Construct the ListViewItem object
         ListViewItem^ item = gcnew ListViewItem;
         
         // Set the Text property to the cursor name.
         item->Text = aCursor->ToString();
         
         // Set the Tag property to the cursor.
         item->Tag = aCursor;
         
         // Add the ListViewItem to the ListView.
         ListView1->Items->Add( item );
      }
   }
private void InitializeListViewItems()
{
    ListView1.View = View.List;

    Cursor[] favoriteCursors = new Cursor[]{Cursors.Help, 
        Cursors.Hand, Cursors.No, Cursors.Cross};

    // Populate the ListView control with the array of Cursors.
    foreach ( Cursor aCursor in favoriteCursors )
    {

        // Construct the ListViewItem object
        ListViewItem item = new ListViewItem();

        // Set the Text property to the cursor name.
        item.Text = aCursor.ToString();

        // Set the Tag property to the cursor.
        item.Tag = aCursor;

        // Add the ListViewItem to the ListView.
        ListView1.Items.Add(item);
    }
}
Private Sub InitializeListViewItems()
    ListView1.View = View.List
    Dim aCursor As Cursor

    Dim favoriteCursors() As Cursor = New Cursor() _
                {Cursors.Help, Cursors.Hand, Cursors.No, Cursors.Cross}

    ' Populate the ListView control with the array of Cursors.
    For Each aCursor In favoriteCursors

        ' Construct the ListViewItem object
        Dim item As New ListViewItem

        ' Set the Text property to the cursor name.
        item.Text = aCursor.ToString

        ' Set the Tag property to the cursor.
        item.Tag = aCursor

        ' Add the ListViewItem to the ListView.
        ListView1.Items.Add(item)
    Next
End Sub

설명

Text 속성을 사용하면 항목에 대해 표시되는 텍스트를 변경할 수 있습니다. 의 ListViewItem 텍스트가 259자를 초과하면 안 되거나 예기치 않은 동작이 발생할 수 있습니다.

, ForeColorFont 속성을 사용하여 BackColor텍스트가 표시되는 방식을 지정할 수 있습니다. 클래스는 ListView 텍스트가 다음 줄로 줄 바꿈되는지 아니면 한 줄에 표시되는지를 결정하는 속성을 제공합니다 LabelWrap .

적용 대상

추가 정보