Foro de elhacker.net

Programación => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: bybaal en 20 Marzo 2017, 01:39 am



Título: Ayuda con ListView
Publicado por: bybaal en 20 Marzo 2017, 01:39 am
Alguien me pudiera ayudar dandome alguna idea de como pudiera ser posible poner un encabezado de filas en un listview en vista detalles, o sea, lo mismo que el encabezado de columnas, pero para las filas

gracias de antemano


Título: Re: Ayuda con ListView
Publicado por: okik en 20 Marzo 2017, 22:35 pm
o sea, lo que quieres es un DataGridView


Código
  1. Public Class Form1
  2.    Dim WithEvents dtgw As New DataGridView
  3.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  4.        Me.Controls.Add(dtgw)
  5.        Me.Width = 510
  6.        With dtgw
  7.            .Size = New Size(500, 200)
  8.            .ColumnHeadersVisible = False  'Oculta las cabeceras horizonteles
  9.            .RowHeadersVisible = True
  10.            .GridColor = Color.White  'Color de las rejillas
  11.            .ColumnCount = 3
  12.            .Columns.Item(0).Name = "Columna 1"
  13.            .Columns.Item(1).Name = "Columna 2"
  14.            .Columns.Item(2).Name = "Columna 3"
  15.            .RowCount = 10
  16.            .RowHeadersWidth = 80
  17.            For Index As Integer = 0 To 9
  18.  
  19.                .Rows.Item(Index).HeaderCell.Value = "Fila " & Index + 1
  20.            Next
  21.        End With
  22.  
  23.         For columna = 0 To 2
  24.            For fila = 0 To 9
  25.                dtgw.Item(columna, fila).Value = "contenido c" & columna & "- f" & fila
  26.            Next fila
  27.        Next columna
  28.  
  29.  
  30.    End Sub
  31. End Class

Mírate las propiedades del objeto tiene muchas formas de trabajar con el objeto y propiedades


Título: Re: Ayuda con ListView
Publicado por: bybaal en 2 Abril 2017, 01:50 am
Muchas Gracias, era eso precisamente lo que estaba buscando.


Título: Re: Ayuda con ListView
Publicado por: okik en 2 Abril 2017, 09:25 am
si quieres quitar el triángulito indicador [►   ] de la fila tan solo debes agregar el siguiente código:

Código
  1.    Private Sub dtgw_RowPrePaint(sender As Object, e As DataGridViewRowPrePaintEventArgs) Handles dtgw.RowPrePaint
  2.       e.PaintHeader(DataGridViewPaintParts.Background _
  3.                      Or DataGridViewPaintParts.Border _
  4.                      Or DataGridViewPaintParts.Focus _
  5.                      Or DataGridViewPaintParts.SelectionBackground _
  6.                      Or DataGridViewPaintParts.ContentForeground)
  7.        e.Handled = True
  8.    End Sub
  9.    Private Sub dtgw_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles dtgw.CellFormatting
  10.        'Texto de la cabecera de la fila
  11.        'dtgw.Rows(e.RowIndex).HeaderCell.Value = "Fila-" & e.RowIndex.ToString()
  12.    End Sub

FUENTE:

Help removing indicator/pointer in row header of datagridview (https://social.msdn.microsoft.com/Forums/windows/en-US/346e5839-1813-472b-8b3a-7344118819b3/help-removing-indicatorpointer-in-row-header-of-datagridview?forum=winformsdatacontrols)