ListViewItem.ItemType Propriedade

Definição

Obtém o tipo de item do objeto ListViewItem.Gets the item type of the ListViewItem object.

public:
 property System::Web::UI::WebControls::ListViewItemType ItemType { System::Web::UI::WebControls::ListViewItemType get(); };
public System.Web.UI.WebControls.ListViewItemType ItemType { get; }
member this.ItemType : System.Web.UI.WebControls.ListViewItemType
Public ReadOnly Property ItemType As ListViewItemType

Valor da propriedade

ListViewItemType

Um dos valores de ListViewItemType.One of the ListViewItemType values.

Exemplos

O exemplo a seguir mostra como usar a ItemType propriedade para determinar se o item que está sendo criado é um item de dados.The following example shows how to use the ItemType property to determine whether the item that is being created is a data item. Se o item for um item de dados, o endereço de email será exibido em itálico.If the item is a data item, the email address is displayed in italic. Este exemplo de código faz parte de um exemplo maior fornecido para a ListViewItem classe.This code example is part of a larger example provided for the ListViewItem class.

protected void ContactsListView_ItemCreated(object sender, ListViewItemEventArgs e)
{
  // Retrieve the current item.
  ListViewItem item = e.Item;

  // Verify if the item is a data item.
  if (item.ItemType == ListViewItemType.DataItem)
  {
    // Get the EmailAddressLabel Label control in the item.
    Label EmailAddressLabel = (Label)item.FindControl("EmailAddressLabel");
    
    // Display the email address in italics.
    EmailAddressLabel.Font.Italic = true;
  }
}
Protected Sub ContactsListView_ItemCreated(ByVal sender As Object, ByVal e As ListViewItemEventArgs)
  
  ' Retrieve the current item.
  Dim item As ListViewItem = e.Item
  
  ' Verify if the item is a data item.
  If item.ItemType = ListViewItemType.DataItem Then
          
    ' Get the EmailAddressLabel Label control in the item.      
    Dim EmailAddressLabel As Label = CType(item.FindControl("EmailAddressLabel"), Label)
    
    ' Display the email address in italics.
    EmailAddressLabel.Font.Italic = True
          
  End If

End Sub

Comentários

Use a ItemType propriedade para determinar o tipo de item que o ListViewItem objeto representa, conforme listado na tabela a seguir.Use the ItemType property to determine the type of item that the ListViewItem object represents, as listed in the following table.

Tipo de itemItem type DescriçãoDescription
DataItem Um item de dados no controle ListView.A data item in the ListView control.
InsertItem Um item de inserção no controle ListView.An insert item in the ListView control.
EmptyItem Um item vazio no controle ListView .An empty item in the ListView control. O item vazio é exibido quando o ListView controle não tem nenhum registro a ser exibido ou quando um grupo no controle não ListView tem mais registros a serem exibidos.The empty item is displayed when the ListView control does not have any records to display, or when a group in the ListView control does not have any more records to display.

Normalmente, você usa essa propriedade para determinar o tipo de um item antes de executar uma operação.You typically use this property to determine an item's type before you perform an operation.

Aplica-se a

Confira também