有谁知道如何在Datagrid视图列中添加单选按钮?单细胞需要三个单选按钮..
答案 0 :(得分:1)
您必须为DataGridView
创建自己的单元格和列。它有点棘手,但在这里你有MSDN的所有步骤:
http://msdn.microsoft.com/en-us/library/aa730882(v=vs.80).aspx
答案 1 :(得分:-1)
这里我有一个简单的方法使用选择的单选按钮和 未选择的透明PNG图像
http://how2doinvbdotnet.blogspot.in/
检查我的博客: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