pontoNETpt
A comunidade PontoNetPT está direccionada a todos os programadores que trabalhem com a plataforma .NET.
Datagrid Sub-header - Exemplo 1 [VB.NET]

Bom... Vou começar a postar bastante coisa sobre personalização de Datagrids, tem muita gente com dúvidas sobre esse assunto.

Nesse primeiro post vou abordar um exemplo de sub-header que fiz em VB.NET.
mas fique tranquilo pois é bem fácil de fazer usando o evento ItemCreated do Datagrid.

Como o slogan do blog é "Código sem enrolação!!!",  tá aí o efeito deste post. :)
O código ilustra a seguinte imagem(clique na imagem para ampliar):


Private

Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemCreated

If e.Item.ItemType = ListItemType.Header Then
   Dim dgItem As DataGridItem
   Dim dgCell As TableCell
   Dim dgCell2 As TableCell

  
'Novo Header
  
dgItem = New DataGridItem(0, 0, ListItemType.Header)
   'Celula "Dados Pessoais"
   dgCell = New TableCell
   'Celula "Telefones de Contato"
   dgCell2 = New TableCell
  
   'Colunas que "Dados Pessoais" vai ocupar
   dgCell.ColumnSpan = 4
   'Colunas que "Telefones de Contato" vai ocupar
   dgCell2.ColumnSpan = 3

   'Conteudo das Celulas
   dgCell.Text = "Dados Pessoais"
   dgCell2.Text = "Telefones de Contato"

   'Adiciona Celulas no DataGridItem
   dgItem.Cells.Add(dgCell)
   dgItem.Cells.Add(dgCell2)

   'Cor da Fonte e Fundo da Celula
   dgItem.ForeColor = Color.FromArgb(0, 0, 0)
   dgItem.BackColor = Color.FromArgb(199, 199, 199)

   'Adiciona DataGridItem no DataGrid no indice 0
   DataGrid1.Controls(0).Controls.AddAt(0, dgItem)

End If

End Sub

Falowwww.... Até o próximo post!!!
Abraços,
Pedro


Posted 7-4-2006 12:53 por Pedro Antonio Seixas Subutzki

Comments

Anonymous wrote re: Datagrid Sub-header - Exemplo 1 [VB.NET]
on 1-7-2009 2:20
muito bom!
parabéns!
dom pedrito - RS (Brasil)
Anonymous wrote re: Datagrid Sub-header - Exemplo 1 [VB.NET]
on 1-7-2009 2:20
É um código muito util! Muito bom.
Obrigado. (Portugal)
Anonymous wrote re: Datagrid Sub-header - Exemplo 1 [VB.NET]
on 2-7-2009 2:19
muito bom!
parabéns!
dom pedrito - RS (Brasil)
Anonymous wrote re: Datagrid Sub-header - Exemplo 1 [VB.NET]
on 2-7-2009 2:19
É um código muito util! Muito bom.
Obrigado. (Portugal)

Add a Comment

(requerido)  
(opcional)
(requerido)  
Remember Me?
If you can't read this number refresh your screen
Enter the numbers above:  
Powered by Community Server (Commercial Edition), by Telligent Systems