[英]RadioButtons in DataGridView Column VB.NET
誰能知道如何在Datagrid View列中添加單選按鈕嗎? 我在單個單元格中需要三個單選按鈕。
您必須為DataGridView
創建自己的單元格和列。 這有點棘手,但是這里您有MSDN的所有步驟:
http://msdn.microsoft.com/zh-CN/library/aa730882(v=vs.80).aspx
在這里,我有一個簡單的方法使用單選按鈕選中和未選中的透明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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.