VB 6.0中使用msflexgrid控件,删除选中行

2024-12-02 10:18:20
推荐回答(3个)
回答1:

Private Sub Command1_Click()
Dim rSel As Long
With MSFlexGrid1
If .Rows = 0 Or .RowSel = 0 Then Exit Sub
rSel = .RowSel
If rSel <> .Rows - 1 Then

For i = rSel + 1 To .Rows - 1
For j = 1 To .Cols - 1
.TextMatrix(i - 1, j) = .TextMatrix(i, j)
Next
Next

End If

.Rows = .Rows - 1
End With
End Sub

回答2:

On Error GoTo erro
MSHFlexGrid1.RemoveItem MSHFlexGrid1.Row 删除选定的行
erro: '---不能删最后非固定行,所以写下列这段代码
If err.Number = 30015 Then
MSHFlexGrid1.Clear
End If

回答3:

这个实现起来比较麻烦,你还不如用dbgrid控件,这样可以直接删除