ListBox.TopIndex プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ListBox.TopIndex プロパティの意味・解説 

ListBox.TopIndex プロパティ

ListBox最初に表示される項目インデックス取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Dim instance As ListBox
Dim value As Integer

value = instance.TopIndex

instance.TopIndex = value
public int TopIndex { get;
 set; }
/** @property */
public int get_TopIndex ()

/** @property */
public void set_TopIndex (int
 value)

プロパティ
コントロール最初に表示される項目の 0 から始まるインデックス番号

解説解説
使用例使用例

SelectedIndex プロパティTopIndex プロパティ使用し、現在選択されている項目を ListBox表示領域内の項目リスト先頭移動する方法次のコード例示します。さらに、System.Windows.Forms.ListBox.ObjectCollection クラスの RemoveAt メソッド使用して項目を削除する方法、ClearSelected メソッド使用してすべての項目の選択解除する方法についても示します。このコード最初にListBox で現在選択されている項目をリスト先頭移動します。このコード次に、現在選択されている項目より前にある項目をすべて削除しListBox 内の選択をすべて解除します。この例では、項目を含む ListBoxフォーム追加されていて、いずれかの項目が ListBox で現在選択されている必要があります

Private Sub RemoveTopItems()
   ' Determine if the currently selected item in the ListBox 
   ' is the item displayed at the top in the ListBox.
   If listBox1.TopIndex <> listBox1.SelectedIndex Then
      ' Make the currently selected item the top item in the ListBox.
      listBox1.TopIndex = listBox1.SelectedIndex
   End If
   ' Remove all items before the top item in the ListBox.
   Dim x As Integer
   For x = listBox1.SelectedIndex - 1 To 0
 Step -1
      listBox1.Items.RemoveAt(x)
   Next x

   ' Clear all selections in the ListBox.
   listBox1.ClearSelected()
End Sub 'RemoveTopItems
private void RemoveTopItems()
{
   // Determine if the currently selected item in the ListBox 
   // is the item displayed at the top in the ListBox.
   if (listBox1.TopIndex != listBox1.SelectedIndex)
      // Make the currently selected item the top item in the ListBox.
      listBox1.TopIndex = listBox1.SelectedIndex;

   // Remove all items before the top item in the ListBox.
   for (int x = (listBox1.SelectedIndex -1);
 x >= 0; x--)
   {
      listBox1.Items.RemoveAt(x);
   }

   // Clear all selections in the ListBox.
   listBox1.ClearSelected();
}
private:
   void RemoveTopItems()
   {
      // Determine if the currently selected item in the ListBox 
      // is the item displayed at the top in the ListBox.
      if ( listBox1->TopIndex != listBox1->SelectedIndex
 )

      // Make the currently selected item the top item in the ListBox.
      listBox1->TopIndex = listBox1->SelectedIndex;

      // Remove all items before the top item in the ListBox.
      for ( int x = (listBox1->SelectedIndex
 - 1); x >= 0; x-- )
      {
         listBox1->Items->RemoveAt( x );
      }

      // Clear all selections in the ListBox.
      listBox1->ClearSelected();
   }
private void RemoveTopItems()
{
    // Determine if the currently selected item in the ListBox 
    // is the item displayed at the top in the ListBox.
    if (listBox1.get_TopIndex() != listBox1.get_SelectedIndex())
 {
        // Make the currently selected item the top item in the ListBox.
        listBox1.set_TopIndex(listBox1.get_SelectedIndex());
    }
    // Remove all items before the top item in the ListBox.
    for (int x = listBox1.get_SelectedIndex()
 - 1; x >= 0; x--) {
        listBox1.get_Items().RemoveAt(x);
    }
    // Clear all selections in the ListBox.
    listBox1.ClearSelected();
} //RemoveTopItems
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からListBox.TopIndex プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からListBox.TopIndex プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からListBox.TopIndex プロパティを検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ListBox.TopIndex プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ListBox.TopIndex プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS