Solved

no change-event checkbox in datagridview

Posted on 2007-11-21
4
1,261 Views
Last Modified: 2009-06-15
I have a datagridview but i can't find the change-event of the checkbox.

Thanks in advance.

Dirk
0
Comment
Question by:dgb
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
razo earned 500 total points
Comment Utility
u can check the cellvaluechanged or cellcontentclick events
0
 

Author Comment

by:dgb
Comment Utility
The cellvaluechanged doesn't fire when a checkbox has been checked/unchecked.
(it does fire when leaving the cell, but that doesn't work for me)

The cellcontentclick is also not working as it should.
When repeatedly click the checkbox i can not ask what the current value is.
0
 

Author Comment

by:dgb
Comment Utility
I've been testing and if i manualy set the checkbox value it seems to go ok

' In the CellContentClick-event
After processing the checked-change i have to execute the following command else it doesn't work.
DataViewGrid.CurrentCell.Value = Not DataViewGrid.CurrentCell.Value
0
 

Expert Comment

by:ahmedcoeur
Comment Utility

Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

       ' my check box colum is the last grid colum

        If e.ColumnIndex = (Me.DataGridView1.Columns.Count - 1) Then

            If Me.DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = True Then

                Me.DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = False

                MessageBox.Show(Me.DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)
 

            Else

                Me.DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = True

                MessageBox.Show(Me.DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value.ToString())

            End If
 

        End If

    End Sub

Open in new window

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now