Click here to Skip to main content
15,893,923 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI EXPERTS

I had a window application. I am using Datagridview inside the gridview i am adding two columns with DataGridViewCheckBoxColumn.
Now when the user click one checkbox i want to disable another checkbox. How can i Make that.

Thanks in advance for your valuable suggestions.

Rgds
Jagadesh
Posted

1 solution

You can use the CellContentClick event. Note that the .Value property will always return false, so use the .GetEditedFormattedValue property to determine whether the checkbox is ticked or not. For example ...
VB
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
    Dim b As Boolean
    If e.ColumnIndex = 0 Then
        b = Convert.ToBoolean(Me.DataGridView1.CurrentCell.GetEditedFormattedValue(e.RowIndex, DataGridViewDataErrorContexts.CurrentCellChange))
        If b Then
            Me.DataGridView1.CurrentRow.Cells(1).ReadOnly = True
        Else
            Me.DataGridView1.CurrentRow.Cells(1).ReadOnly = False
        End If
    End If
End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900