ColumnHeader クラス

定義

ListView コントロール内の単一の列ヘッダー見出しを表示します。

public ref class ColumnHeader : System::ComponentModel::Component, ICloneable
public class ColumnHeader : System.ComponentModel.Component, ICloneable
[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ColumnHeaderConverter))]
public class ColumnHeader : System.ComponentModel.Component, ICloneable
type ColumnHeader = class
    inherit Component
    interface ICloneable
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ColumnHeaderConverter))>]
type ColumnHeader = class
    inherit Component
    interface ICloneable
Public Class ColumnHeader
Inherits Component
Implements ICloneable
継承
属性
実装

次のコード例は、コントロールの初期化を ListView 示しています。 この例では、オブジェクトを作成 ColumnHeader し、列ヘッダーの TextTextAlign および プロパティを Width 設定します。 この例では、 に項目とサブ項目も追加します ListView。 この例を実行するには、次のコードをフォームに貼り付け、フォームのコンストラクターまたはLoadイベント ハンドラーから メソッドを呼び出PopulateListViewします。

private:
   void PopulateListView()
   {
      ListView1->Width = 270;
      ListView1->Location = System::Drawing::Point( 10, 10 );
      
      // Declare and construct the ColumnHeader objects.
      ColumnHeader^ header1;
      ColumnHeader^ header2;
      header1 = gcnew ColumnHeader;
      header2 = gcnew ColumnHeader;
      
      // Set the text, alignment and width for each column header.
      header1->Text = "File name";
      header1->TextAlign = HorizontalAlignment::Left;
      header1->Width = 70;
      header2->TextAlign = HorizontalAlignment::Left;
      header2->Text = "Location";
      header2->Width = 200;
      
      // Add the headers to the ListView control.
      ListView1->Columns->Add( header1 );
      ListView1->Columns->Add( header2 );
            
      // Specify that each item appears on a separate line.
      ListView1->View = View::Details;

      // Populate the ListView.Items property.
      // Set the directory to the sample picture directory.
      System::IO::DirectoryInfo^ dirInfo = gcnew System::IO::DirectoryInfo( "C:\\Documents and Settings\\All Users"
      "\\Documents\\My Pictures\\Sample Pictures" );
      
      // Get the .jpg files from the directory
      array<System::IO::FileInfo^>^files = dirInfo->GetFiles( "*.jpg" );
      
      // Add each file name and full name including path
      // to the ListView.
      if ( files != nullptr )
      {
         System::Collections::IEnumerator^ myEnum = files->GetEnumerator();
         while ( myEnum->MoveNext() )
         {
            System::IO::FileInfo^ file = safe_cast<System::IO::FileInfo^>(myEnum->Current);
            ListViewItem^ item = gcnew ListViewItem( file->Name );
            item->SubItems->Add( file->FullName );
            ListView1->Items->Add( item );
         }
      }
   }
private void PopulateListView()
{
    ListView1.Width = 270;
    ListView1.Location = new System.Drawing.Point(10, 10);

    // Declare and construct the ColumnHeader objects.
    ColumnHeader header1, header2;
    header1 = new ColumnHeader();
    header2 = new ColumnHeader();

    // Set the text, alignment and width for each column header.
    header1.Text = "File name";
    header1.TextAlign = HorizontalAlignment.Left;
    header1.Width = 70;

    header2.TextAlign = HorizontalAlignment.Left;
    header2.Text = "Location";
    header2.Width = 200;

    // Add the headers to the ListView control.
    ListView1.Columns.Add(header1);
    ListView1.Columns.Add(header2);

    // Specify that each item appears on a separate line.
    ListView1.View = View.Details;
    
    // Populate the ListView.Items property.
    // Set the directory to the sample picture directory.
    System.IO.DirectoryInfo dirInfo = 
        new System.IO.DirectoryInfo(
        "C:\\Documents and Settings\\All Users" +
        "\\Documents\\My Pictures\\Sample Pictures");

    // Get the .jpg files from the directory
    System.IO.FileInfo[] files = dirInfo.GetFiles("*.jpg");

    // Add each file name and full name including path
    // to the ListView.
    if (files != null)
    {
        foreach ( System.IO.FileInfo file in files )
        {
            ListViewItem item = new ListViewItem(file.Name);
            item.SubItems.Add(file.FullName);
            ListView1.Items.Add(item);
        }
    }
}
Private Sub PopulateListView()
    ListView1.Width = 270
    ListView1.Location = New System.Drawing.Point(10, 10)

    ' Declare and construct the ColumnHeader objects.
    Dim header1, header2 As ColumnHeader
    header1 = New ColumnHeader
    header2 = New ColumnHeader

    ' Set the text, alignment and width for each column header.
    header1.Text = "File name"
    header1.TextAlign = HorizontalAlignment.Left
    header1.Width = 70

    header2.TextAlign = HorizontalAlignment.Left
    header2.Text = "Location"
    header2.Width = 200

    ' Add the headers to the ListView control.
    ListView1.Columns.Add(header1)
    ListView1.Columns.Add(header2)

    ' Specify that each item appears on a separate line.
    ListView1.View = View.Details

    ' Populate the ListView.Items property.
    ' Set the directory to the sample picture directory.
    Dim dirInfo As New System.IO.DirectoryInfo _
        ("C:\Documents and Settings\All Users" _
        & "\Documents\My Pictures\Sample Pictures")
    Dim file As System.IO.FileInfo

    ' Get the .jpg files from the directory
    Dim files() As System.io.FileInfo = dirInfo.GetFiles("*.jpg")

    ' Add each file name and full name including path
    ' to the ListView.
    If (files IsNot Nothing) Then
        For Each file In files
            Dim item As New ListViewItem(file.Name)
            item.SubItems.Add(file.FullName)
            ListView1.Items.Add(item)
        Next
    End If
End Sub

注釈

列ヘッダーは、見出しテキストを ListView 含むコントロール内の項目です。 ColumnHeaderオブジェクトは、 クラスの メソッドをAdd使用して にListView.ColumnHeaderCollection追加ListViewできます。 列のグループを にListView追加するには、 クラスの メソッドをAddRangeListView.ColumnHeaderCollection使用できます。 クラスの プロパティをIndex使用して、 ColumnHeader が 内のListView.ColumnHeaderCollectionどこにあるかをColumnHeader判断できます。

ColumnHeader には、 Text コントロールに表示されるテキストと TextAlign 列ヘッダー内のテキストの配置を設定する プロパティと プロパティが用意されています。 がコントロールに ColumnHeader 関連付 ListView けられているかどうかを判断するには、 プロパティを ListView 参照します。 をコピー ColumnHeader して別 ListView のコントロールで使用する場合は、 メソッドを Clone 使用できます。

コンストラクター

ColumnHeader()

ColumnHeader クラスの新しいインスタンスを初期化します。

ColumnHeader(Int32)

イメージを指定して ColumnHeader クラスの新しいインスタンスを初期化します。

ColumnHeader(String)

イメージを指定して ColumnHeader クラスの新しいインスタンスを初期化します。

プロパティ

CanRaiseEvents

コンポーネントがイベントを発生させることがきるかどうかを示す値を取得します。

(継承元 Component)
Container

IContainer を含む Component を取得します。

(継承元 Component)
DesignMode

Component が現在デザイン モードかどうかを示す値を取得します。

(継承元 Component)
DisplayIndex

現在表示されている列を基準とした列の表示順序を設定または取得します。

Events

Component に結び付けられているイベント ハンドラーのリストを取得します。

(継承元 Component)
ImageIndex

ColumnHeader に表示されるイメージのインデックスを取得または設定します。

ImageKey

列に表示されるイメージのキーを取得または設定します。

ImageList

ColumnHeader に関連付けられているイメージ リストを取得します。

Index

この列にある ListView コントロールの ListView.ColumnHeaderCollection を使用して、位置を取得します。

ListView

ListView が格納されている ColumnHeader コントロールを取得します。

Name

ColumnHeader の名前を取得または設定します。

Site

ComponentISite を取得または設定します。

(継承元 Component)
Tag

ColumnHeader に関連付けるデータを含むオブジェクトを取得または設定します。

Text

列ヘッダーに表示されるテキストを取得または設定します。

TextAlign

ColumnHeader で表示されたテキストの水平方向の配置を取得または設定します。

Width

列の幅を取得または設定します。

メソッド

AutoResize(ColumnHeaderAutoResizeStyle)

列の幅を、サイズ変更スタイルで示された幅にサイズ変更します。

Clone()

どのリスト ビュー コントロールにも結び付けられていない、現在の ColumnHeader のコピーを作成します。

CreateObjRef(Type)

リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。

(継承元 MarshalByRefObject)
Dispose()

Component によって使用されているすべてのリソースを解放します。

(継承元 Component)
Dispose(Boolean)

ColumnHeader で使用されていたリソース (メモリを除く) を解放します。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetLifetimeService()
古い.

対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
GetService(Type)

Component またはその Container で提供されるサービスを表すオブジェクトを返します。

(継承元 Component)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
InitializeLifetimeService()
古い.

このインスタンスの有効期間ポリシーを制御する有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
MemberwiseClone(Boolean)

現在の MarshalByRefObject オブジェクトの簡易コピーを作成します。

(継承元 MarshalByRefObject)
ToString()

Component の名前 (存在する場合) を格納する String を返します。 このメソッドはオーバーライドできません。

イベント

Disposed

Dispose() メソッドの呼び出しによってコンポーネントが破棄されるときに発生します。

(継承元 Component)

適用対象

こちらもご覧ください