ColumnHeader ColumnHeader ColumnHeader ColumnHeader Class

Definición

Muestra un solo encabezado de columna en un control ListView.Displays a single column header in a ListView control.

public ref 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
Public Class ColumnHeader
Inherits Component
Implements ICloneable
Herencia
Atributos
Implementaciones

Ejemplos

En el ejemplo de código siguiente se ListView muestra cómo inicializar un control.The following code example demonstrates initializing a ListView control. En el ejemplo ColumnHeader se crean objetos y se establecen las Textpropiedades TextAlign y Width del encabezado de columna.The example creates ColumnHeader objects and sets the column header's Text, TextAlign and Width properties. En el ejemplo también se agregan elementos y subelementos a ListView.The example also adds items and subitems to the ListView. Para ejecutar este ejemplo, pegue el siguiente código en un formulario y llame PopulateListView al método desde el constructor del formulario Load o el controlador de eventos.To run this example paste the following code in a form and call the PopulateListView method from the form's constructor or Load event handler.

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

Comentarios

Un encabezado de columna es un elemento de ListView un control que contiene el texto del título.A column header is an item in a ListView control that contains heading text. ColumnHeaderlos objetos se pueden agregar a ListView mediante el Add método de la ListView.ColumnHeaderCollection clase.ColumnHeader objects can be added to a ListView using the Add method of the ListView.ColumnHeaderCollection class. Para agregar un grupo de columnas a un ListView, puede utilizar el AddRange método de la ListView.ColumnHeaderCollection clase.To add a group of columns to a ListView, you can use the AddRange method of the ListView.ColumnHeaderCollection class. Puede utilizar la Index propiedad de la ColumnHeader clase para determinar dónde se encuentra ColumnHeader ListView.ColumnHeaderCollectionel en.You can use the Index property of the ColumnHeader class to determine where the ColumnHeader is located in the ListView.ColumnHeaderCollection.

ColumnHeaderproporciona las Text propiedades TextAlign y para establecer el texto que se muestra en el control y la alineación del texto en el encabezado de columna.ColumnHeader provides the Text and TextAlign properties to set the text displayed in the control and the alignment of the text in the column header. Para determinar si un ColumnHeader objeto está asociado a ListView un control, puede hacer referencia ListView a la propiedad.To determine whether a ColumnHeader is associated with a ListView control, you can reference the ListView property. Si desea copiar un ColumnHeader para usarlo en otro ListView control, puede utilizar el Clone método.If you want to copy a ColumnHeader for use in another ListView control, you can use the Clone method.

Constructores

ColumnHeader() ColumnHeader() ColumnHeader() ColumnHeader()

Inicializa una nueva instancia de la clase ColumnHeader.Initializes a new instance of the ColumnHeader class.

ColumnHeader(Int32) ColumnHeader(Int32) ColumnHeader(Int32) ColumnHeader(Int32)

Inicializa una nueva instancia de la clase ColumnHeader con la imagen especificada.Initializes a new instance of the ColumnHeader class with the image specified.

ColumnHeader(String) ColumnHeader(String) ColumnHeader(String) ColumnHeader(String)

Inicializa una nueva instancia de la clase ColumnHeader con la imagen especificada.Initializes a new instance of the ColumnHeader class with the image specified.

Propiedades

CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

Obtiene un valor que indica si el componente puede generar un evento.Gets a value indicating whether the component can raise an event.

(Inherited from Component)
Container Container Container Container

Obtiene IContainer que contiene Component.Gets the IContainer that contains the Component.

(Inherited from Component)
DesignMode DesignMode DesignMode DesignMode

Obtiene un valor que indica si Component está actualmente en modo de diseño.Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
DisplayIndex DisplayIndex DisplayIndex DisplayIndex

Obtiene o establece el orden de presentación de la columna respecto de las columnas actualmente mostradas.Gets or sets the display order of the column relative to the currently displayed columns.

Events Events Events Events

Obtiene la lista de controladores de eventos asociados a Component.Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
ImageIndex ImageIndex ImageIndex ImageIndex

Obtiene o establece el índice de la imagen que se muestra en el objeto ColumnHeader.Gets or sets the index of the image displayed in the ColumnHeader.

ImageKey ImageKey ImageKey ImageKey

Obtiene o establece la clave de la imagen que se muestra en el objeto.Gets or sets the key of the image displayed in the column.

ImageList ImageList ImageList ImageList

Obtiene la lista de imágenes asociadas con el objeto ColumnHeader.Gets the image list associated with the ColumnHeader.

Index Index Index Index

Obtiene la ubicación con el objeto ListView del control ListView.ColumnHeaderCollection de esta columna.Gets the location with the ListView control's ListView.ColumnHeaderCollection of this column.

ListView ListView ListView ListView

Obtiene el control ListView en que se encuentra ColumnHeader.Gets the ListView control the ColumnHeader is located in.

Name Name Name Name

Obtiene o establece el nombre de ColumnHeader.Gets or sets the name of the ColumnHeader.

Site Site Site Site

Obtiene o establece el ISite de Component.Gets or sets the ISite of the Component.

(Inherited from Component)
Tag Tag Tag Tag

Obtiene o establece un objeto que contiene datos que se van a asociar con ColumnHeader.Gets or sets an object that contains data to associate with the ColumnHeader.

Text Text Text Text

Obtiene o establece el texto que se muestra en el encabezado de columna.Gets or sets the text displayed in the column header.

TextAlign TextAlign TextAlign TextAlign

Obtiene o establece la alineación horizontal del texto que se muestra en ColumnHeader.Gets or sets the horizontal alignment of the text displayed in the ColumnHeader.

Width Width Width Width

Obtiene o establece el ancho de la columna.Gets or sets the width of the column.

Métodos

AutoResize(ColumnHeaderAutoResizeStyle) AutoResize(ColumnHeaderAutoResizeStyle) AutoResize(ColumnHeaderAutoResizeStyle) AutoResize(ColumnHeaderAutoResizeStyle)

Cambia el ancho de la columna según lo indicado en el estilo de cambio de tamaño.Resizes the width of the column as indicated by the resize style.

Clone() Clone() Clone() Clone()

Crea una copia idéntica del objeto ColumnHeader actual que no está agregada a ningún control de vista de lista.Creates an identical copy of the current ColumnHeader that is not attached to any list view control.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Crea un objeto que contiene toda la información relevante necesaria para generar un proxy utilizado para comunicarse con un objeto remoto.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

Libera todos los recursos que usa Component.Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Se deshace de los recursos (distintos de la memoria) que usa ColumnHeader.Disposes of the resources (other than memory) used by the ColumnHeader.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Recupera el objeto de servicio de duración actual que controla la directiva de duración de esta instancia.Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

Devuelve un objeto que representa el servicio suministrado por Component o por Container.Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtiene un objeto de servicio de duración para controlar la directiva de duración de esta instancia.Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Crea una copia superficial del objeto MarshalByRefObject actual.Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ToString() ToString() ToString() ToString()

Devuelve una String que contiene el nombre del Component, si existe.Returns a String containing the name of the Component, if any. Este método no se debe invalidar.This method should not be overridden.

Eventos

Disposed Disposed Disposed Disposed

Se produce cuando el componente se elimina mediante una llamada al método Dispose().Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)

Se aplica a

Consulte también: