2013-01-18 120 views
0

任何人都可以知道如何在Datagrid視圖列中添加單選按鈕?我需要單個單元格中的三個單選按鈕。DataGridView列中的RadioButton列VB.NET

+2

更新您的代碼爲datagridview這裏得到很好的答案 –

+0

是的..我知道。但我嘗試編輯列屬性。只有'datagridview複選框列'和'datagridview combobox列'。 'Datagridview radiobutton列'不存在。我是新手vb.net – Thanzeem

回答

-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