0

谁能知道如何在 Datagrid 视图列中添加单选按钮?我需要单个单元格中的三个单选按钮..

4

2 回答 2

1

您必须为DataGridView. 它有点棘手,但这里有 MSDN 的所有步骤:

http://msdn.microsoft.com/en-us/library/aa730882(v=vs.80).aspx

于 2013-01-18T06:58:37.243 回答
-2

这里我有一个简单的方法使用单选按钮选中和未选中透明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
于 2013-11-21T06:29:08.820 回答