Skip to content

CheckBox in DGV Column Header #278

Closed

Description

@itg-assistant

Cris asked 2016-09-21 21:21:30 UTC

Hi,

Is it possible to put a checkbox in a DGV column header ? This is a nice-to-have feature to select/unselect all rows.

Thanks.

Activity

  1. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2016-09-21 21:27:40 UTC

    It is possible, but not yet :)

    The DGV cells in Wisej have the Control property which is meant to be used to include a control in the cell, any cell. The top left cell is DGV.TopLeftHeaderCell, so you can assign a control to the call, the control can be created dynamically and all the events are wired back normally.

    However the property is not wired on the client side yet and I'm not sure it will be by the first release.

    Best,

    Luca

  2. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Cris answered 2016-09-21 21:43:37 UTC

    Hi Luca,

    Got you. And I understand that your target first release date is fast approaching. What I asked maybe just considered as an enhancement and can be done after the first release if you are running out of time.

    Just please include that in your TDL.

    Thanks.

  3. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Huỳnh Tấn Phát answered 2019-09-30 10:55:55 UTC

    Code here:
    Public Class vsDataGridViewCheckBoxColumn
    Inherits Wisej.Web.DataGridViewCheckBoxColumn

    #Region “Properties”
    Private _IsHeaderCheckBox As Boolean

    Public Property IsHeaderCheckBox() As Boolean
        Get
            Return Me._IsHeaderCheckBox
        End Get
        Set(value As Boolean)
            Me._IsHeaderCheckBox = value
            Me.checkBox1.Visible = value
            Try
                Me.DataGridView.Update()
            Catch ex As Exception
    
            End Try
        End Set
    End Property
    

    #End Region
    #Region “Variables”
    Private checkBox1 As New vsCheckBox()
    #End Region
    #Region “Design”
    Sub New()
    Me.checkBox1 = New vsCheckBox()
    Me.checkBox1.Visible = False
    Me.checkBox1.Text = “”
    AddHandler Me.checkBox1.CheckedChanged, AddressOf Me.checkBox1_CheckedChanged

        Me.HeaderCell.Control = Me.checkBox1
    End Sub
    Private Sub checkBox1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim i As Integer
        For i = 0 To Me.DataGridView.RowCount – 1
            Me.DataGridView.Item(Me.Index, i).Value = Me.checkBox1.Checked
        Next
    End Sub
    

    #End Region
    End Class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GeneralQuestions, how-tos and everything else.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions