Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi all,

how to add radio button in datagridview in windows application.

thanks.
Posted

 
Share this answer
 
Hi,Here I have a Simple Method Use a Radio Button Selected and UnSelected Transparent PNG image

http://how2doinvbdotnet.blogspot.in/2013/11/how-to-add-radiobutton-control.html[^]

check my Blog :how2doinvbdotnet.blogspot.in

Public Class Form1
Dim ColType(,) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
With DataGridView1
.RowCount = 5
.ColumnCount = 3
For i As Integer = 0 To .RowCount - 1
.Rows(i).Cells(2) = New DataGridViewImageCell
.Rows(i).Cells(2).Style.Alignment = DataGridViewContentAlignment.MiddleCenter
.Rows(i).Cells(2).Value = My.Resources.RadioUnsel
.Rows(i).Cells(2).Tag = 2
Next
End With
End Sub

Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As _System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
With DataGridView1
If .Rows(e.RowIndex).Cells(e.ColumnIndex).Tag = 2 Then
For i As Integer = 0 To .RowCount - 1
If e.RowIndex <> i Then
.Rows(i).Cells(e.ColumnIndex).Value = My.Resources.RadioUnsel
Else
.Rows(i).Cells(e.ColumnIndex).Value = My.Resources.RadioButtonSel
End If
Next
End If
End With
End Sub
End Class
 
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