删除Datagridview Cell(s)选择

时间:2015-01-23 16:40:41

标签: vb.net datagridview

我想要做的是在datagridview中选择行(0).cells(0)到行(1).cells(6)(只是一个例子,选择会改变),按一个按钮,然后是所有单元格所选范围删除或等于""。

任何帮助将不胜感激。感谢

1 个答案:

答案 0 :(得分:0)

以下是代码:

    Private Sub clearpb_Click(sender As Object, e As EventArgs) Handles clearpb.Click

    Dim myrowcount As Integer = Me.datagridviewentry.Rows.Count
    Dim mycolcount As Integer = Me.datagridviewentry.Columns.Count

    a = 0
    Do While a < myrowcount
        b = 0
        Do While b < mycolcount
            If Me.datagridviewentry.Rows(a).Cells(b).Selected = True Then
                Me.datagridviewentry.Rows(a).Cells(b).Value = ""
            End If
            b += 1
        Loop
        a += 1
    Loop

End Sub