ListView.HideSelection ListView.HideSelection ListView.HideSelection ListView.HideSelection Property

정의

컨트롤이 포커스를 잃었을 때 해당 컨트롤에서 선택된 항목이 강조 표시된 상태로 남아 있는지 여부를 나타내는 값을 가져오거나 설정합니다.Gets or sets a value indicating whether the selected item in the control remains highlighted when the control loses focus.

public:
 property bool HideSelection { bool get(); void set(bool value); };
public bool HideSelection { get; set; }
member this.HideSelection : bool with get, set
Public Property HideSelection As Boolean

속성 값

컨트롤이 포커스를 잃었을 때 선택된 항목이 강조 표시되지 않으면 true이고, 컨트롤이 포커스를 잃었을 때 선택된 항목이 강조 표시되면 false입니다.true if the selected item does not appear highlighted when the control loses focus; false if the selected item still appears highlighted when the control loses focus. 기본값은 true입니다.The default is true.

예제

다음 코드 예제는 ListView 여러 항목을 선택할 수 있도록 합니다.The following code example demonstrates a ListView that allows multiple items to be selected. 예제 설정에는 HideSelectionHeaderStyle 속성입니다.The example demonstrates setting the HideSelection and HeaderStyle properties. 보여 줍니다 합니다 ColumnHeader.Text, ColumnHeader.TextAlign, 및 ColumnHeader.Width 속성입니다.It also demonstrates the ColumnHeader.Text, ColumnHeader.TextAlign, and ColumnHeader.Width properties. 이 예제를 실행 하려면 다음 코드를 포함 하는 형식으로 붙여넣습니다를 ListView 개체인 ListView1TextBox 라는 TextBox1합니다.To run this example, paste the following code into a form that contains a ListView object named ListView1 and a TextBox named TextBox1. 호출 된 InitializeListView 폼의 생성자에서 메서드 또는 Load 이벤트 처리기입니다.Call the InitializeListView method from the form's constructor or Load event handler.

// This method adds two columns to the ListView, setting the Text 
// and TextAlign, and Width properties of each ColumnHeader.  The 
// HeaderStyle property is set to NonClickable since the ColumnClick 
// event is not handled.  Finally the method adds ListViewItems and 
// SubItems to each column.
void InitializeListView()
{
   this->ListView1 = gcnew System::Windows::Forms::ListView;
   this->ListView1->BackColor = System::Drawing::SystemColors::Control;
   this->ListView1->Dock = System::Windows::Forms::DockStyle::Top;
   this->ListView1->Location = System::Drawing::Point( 0, 0 );
   this->ListView1->Name = "ListView1";
   this->ListView1->Size = System::Drawing::Size( 292, 130 );
   this->ListView1->TabIndex = 0;
   this->ListView1->View = System::Windows::Forms::View::Details;
   this->ListView1->MultiSelect = true;
   this->ListView1->HideSelection = false;
   this->ListView1->HeaderStyle = ColumnHeaderStyle::Nonclickable;
   ColumnHeader^ columnHeader1 = gcnew ColumnHeader;
   columnHeader1->Text = "Breakfast Item";
   columnHeader1->TextAlign = HorizontalAlignment::Left;
   columnHeader1->Width = 146;
   ColumnHeader^ columnHeader2 = gcnew ColumnHeader;
   columnHeader2->Text = "Price Each";
   columnHeader2->TextAlign = HorizontalAlignment::Center;
   columnHeader2->Width = 142;
   this->ListView1->Columns->Add( columnHeader1 );
   this->ListView1->Columns->Add( columnHeader2 );
   array<String^>^foodList = {"Juice","Coffee","Cereal & Milk","Fruit Plate","Toast & Jelly","Bagel & Cream Cheese"};
   array<String^>^foodPrice = {"1.09","1.09","2.19","2.49","1.49","1.49"};
   for ( int count = 0; count < foodList->Length; count++ )
   {
      ListViewItem^ listItem = gcnew ListViewItem( foodList[ count ] );
      listItem->SubItems->Add( foodPrice[ count ] );
      ListView1->Items->Add( listItem );

   }
   this->Controls->Add( ListView1 );
}
  // This method adds two columns to the ListView, setting the Text 
  // and TextAlign, and Width properties of each ColumnHeader.  The 
  // HeaderStyle property is set to NonClickable since the ColumnClick 
  // event is not handled.  Finally the method adds ListViewItems and 
  // SubItems to each column.
  private void InitializeListView()
  {
      this.ListView1 = new System.Windows.Forms.ListView();
      this.ListView1.BackColor = System.Drawing.SystemColors.Control;
      this.ListView1.Dock = System.Windows.Forms.DockStyle.Top;
      this.ListView1.Location = new System.Drawing.Point(0, 0);
      this.ListView1.Name = "ListView1";
      this.ListView1.Size = new System.Drawing.Size(292, 130);
      this.ListView1.TabIndex = 0;
      this.ListView1.View = System.Windows.Forms.View.Details;
      this.ListView1.MultiSelect = true;
      this.ListView1.HideSelection = false;
      this.ListView1.HeaderStyle = ColumnHeaderStyle.Nonclickable;
      
      ColumnHeader columnHeader1 = new ColumnHeader();
      columnHeader1.Text = "Breakfast Item";
      columnHeader1.TextAlign = HorizontalAlignment.Left;
      columnHeader1.Width = 146;

      ColumnHeader columnHeader2 = new ColumnHeader();
      columnHeader2.Text = "Price Each";
      columnHeader2.TextAlign = HorizontalAlignment.Center;
      columnHeader2.Width = 142;

      this.ListView1.Columns.Add(columnHeader1);
      this.ListView1.Columns.Add(columnHeader2);

      string[] foodList = new string[]{"Juice", "Coffee", 
          "Cereal & Milk", "Fruit Plate", "Toast & Jelly", 
          "Bagel & Cream Cheese"};
      string[] foodPrice = new string[]{"1.09", "1.09", "2.19", 
          "2.49", "1.49", "1.49"};
      
      for(int count=0; count < foodList.Length; count++)
      {
          ListViewItem listItem = new ListViewItem(foodList[count]);
          listItem.SubItems.Add(foodPrice[count]);
          ListView1.Items.Add(listItem);
      }
      this.Controls.Add(ListView1);
  }
  
' This method adds two columns to the ListView, setting the Text 
' and TextAlign, and Width properties of each ColumnHeader.  The 
' HeaderStyle property is set to NonClickable since the ColumnClick 
' event is not handled.  Finally the method adds ListViewItems and 
' SubItems to each column.
Private Sub InitializeListView()
    Me.ListView1 = New System.Windows.Forms.ListView
    Me.ListView1.BackColor = System.Drawing.SystemColors.Control
    Me.ListView1.Dock = System.Windows.Forms.DockStyle.Top
    Me.ListView1.Location = New System.Drawing.Point(0, 0)
    Me.ListView1.Name = "ListView1"
    Me.ListView1.Size = New System.Drawing.Size(292, 130)
    Me.ListView1.TabIndex = 0
    Me.ListView1.View = System.Windows.Forms.View.Details
    Me.ListView1.MultiSelect = True
    Me.ListView1.HideSelection = False
    ListView1.HeaderStyle = ColumnHeaderStyle.Nonclickable
    Dim columnHeader1 As New ColumnHeader
    With columnHeader1
        .Text = "Breakfast Item"
        .TextAlign = HorizontalAlignment.Left
        .Width = 146
    End With
    Dim columnHeader2 As New ColumnHeader
    With columnHeader2
        .Text = "Price Each"
        .TextAlign = HorizontalAlignment.Center
        .Width = 142
    End With

    Me.ListView1.Columns.Add(columnHeader1)
    Me.ListView1.Columns.Add(columnHeader2)
    Dim foodList() As String = New String() {"Juice", "Coffee", _
        "Cereal & Milk", "Fruit Plate", "Toast & Jelly", _
        "Bagel & Cream Cheese"}
    Dim foodPrice() As String = New String() {"1.09", "1.09", _
        "2.19", "2.49", "1.49", "1.49"}
    Dim count As Integer
    For count = 0 To foodList.Length - 1
        Dim listItem As New ListViewItem(foodList(count))
        listItem.SubItems.Add(foodPrice(count))
        ListView1.Items.Add(listItem)
    Next
    Me.Controls.Add(Me.ListView1)
End Sub

설명

이 속성 설정 된 경우 false에서 항목을 선택는 ListView 제어 유지와 다른 운영 체제에서 지정한 현재 선택 영역 색을 색 강조 표시 된 때를 ListView 컨트롤이 포커스를 잃을.When this property is set to false, selected items in the ListView control remain highlighted in a different color than the current selection color specified by the operating system when the ListView control loses focus. 사용자 폼에서 다른 컨트롤을 클릭 하거나 다른 창으로 이동 하면 표시 되는 사용자가 선택 되는 항목을 유지 하려면이 속성을 사용할 수 있습니다.You can use this property to keep items that are selected by the user visible when the user clicks a different control on the form or moves to a different window.

참고

애플리케이션의 액세스 가능성을 고려 하는 것이 좋습니다 설정 하는 HideSelection 속성을 false입니다.If you are concerned with the accessibility of your applications, it is recommended that you set the HideSelection property to false.

적용 대상