añadir checkbox a un listview

13/02/2007 - 11:21 por Cristina | Informe spam
Hola!!querria saber como puedo añadir un checkbox a mi listview...Añadiendo
una columna q sea de checkbox???Xo como???Y q cada vez q se realice una
operacion se active el checkbox..alguien m puede dar alguna ayuda xa hacer
esto??Q no se comoGracias!!!
 

Leer las respuestas

#1 Angel. E. Ruiz. P
13/02/2007 - 16:20 | Informe spam
Hola...

prueba con:
Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox

Friend WithEvents ListView1 As System.Windows.Forms.ListView

Public WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.CheckBox1 = New System.Windows.Forms.CheckBox

Me.ListView1 = New System.Windows.Forms.ListView

Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader

Me.SuspendLayout()

'

'CheckBox1

'

Me.CheckBox1.BackColor = System.Drawing.Color.Transparent

Me.CheckBox1.Location = New System.Drawing.Point(40, 16)

Me.CheckBox1.Name = "CheckBox1"

Me.CheckBox1.Size = New System.Drawing.Size(80, 20)

Me.CheckBox1.TabIndex = 1

Me.CheckBox1.Text = "Select all"

'

'ListView1

'

Me.ListView1.CheckBoxes = True

Me.ListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader()
{Me.ColumnHeader1})

Me.ListView1.Location = New System.Drawing.Point(32, 72)

Me.ListView1.Name = "ListView1"

Me.ListView1.Size = New System.Drawing.Size(232, 176)

Me.ListView1.TabIndex = 0

Me.ListView1.View = System.Windows.Forms.View.Details

'

'ColumnHeader1

'

Me.ColumnHeader1.Text = "Select all chkBox controls"

Me.ColumnHeader1.Width = 193

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(690, 479)

Me.Controls.Add(Me.CheckBox1)

Me.Controls.Add(Me.ListView1)

Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle

Me.MaximizeBox = False

Me.Name = "Form1"

Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen

Me.Text = "Form1"

Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

For i As Integer = 0 To 15

Me.ListView1.Items.Add("Item: " & i)

Next

End Sub

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged

For Each lvitem As ListViewItem In Me.ListView1.Items

If lvitem.Checked = False Then

lvitem.Checked = True

Else

lvitem.Checked = False

End If

Next

End Sub

End Class





Saludos cordiales,
Ángel Ruiz
MCTS .NET Framework 2.0 Windows Applications
Caracas - Venezuela
"El conocimiento es un bien, que crece a medida que se comparte"


"Cristina" escribió en el mensaje
news:
Hola!!querria saber como puedo añadir un checkbox a mi
listview...Añadiendo
una columna q sea de checkbox???Xo como???Y q cada vez q se realice una
operacion se active el checkbox..alguien m puede dar alguna ayuda xa hacer
esto??Q no se comoGracias!!!

Preguntas similares