如何在datagridview中添加单选按钮 [英] how to add radio button in datagridview
本文介绍了如何在datagridview中添加单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
如何在windows应用程序的datagridview中添加单选按钮。
谢谢。
Hi all,
how to add radio button in datagridview in windows application.
thanks.
推荐答案
嗨
试试这个链接
为DataGridView控件构建自定义RadioButton单元格和列 [ ^ ]
我在这里简单方法使用单选按钮选定和未选择透明PNG图像
http://how2doinvbdotnet.blogspot.in/2013/11/how-to-add-radiobutton-control.html [ ^ ]
查看我的博客:how2doinvbdotnet.blogspot.in
公共类Form1
Dim ColType(,)As Integer
Private Sub Form1_Load(ByVal sender As System.Object ,ByVal e As System.EventArgs)_
处理MyBase.Load
使用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 >
。行(i).Cells(2).Tag = 2
下一页
结束
End Sub
Private Sub DataGridView1_CellClick(ByVal sender As Object,ByVal e As _System.Windows.Forms.DataGridViewCellEventArgs)处理DataGridView1.CellClick
使用DataGridView1
如果.Rows(e.RowIndex).Cells(e.ColumnIndex).Tag = 2则
对于i as Integer = 0 To .RowCount - 1
如果e.RowIndex<>然后
.Rows(i).Cells(e.ColumnIndex).Value = My.Resources.RadioUnsel
Else
.Rows( i).Cells(e.ColumnIndex).Value = My.Resources.RadioButtonSel
结束如果
下一页
结束如果
结束
结束子
结束班
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
这篇关于如何在datagridview中添加单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文