vb删除MSHFlexGrid1选中的一行行
展开全部
Dim HaveSelected As Boolean '声明一个布尔型变量,用来判断是否做了选择
Private Sub Command1_Click()
If HaveSelected = True Then MSHFlexGrid1.RemoveItem MSHFlexGrid1.RowSel '删除选中的行
End Sub
Private Sub Form_Load() '窗体加载的时候做的准备,一方面添加些数据,另一方面做些初始必须的设置与赋值,这就是初始化
MSHFlexGrid1.Cols = 10 '设置MSHFlexGrid1为十列
MSHFlexGrid1.Rows = 10 '设置MSHFlexGrid1为十行
MSHFlexGrid1.FixedCols = 0 '无固定列
MSHFlexGrid1.FixedRows = 0 '无固定行
For i = 0 To MSHFlexGrid1.Rows - 1 '从第一行到最后一行遍历循环,就跟数数一样
For j = 0 To MSHFlexGrid1.Cols - 1 '从第一列到最后一列遍历循环,就跟数数一样
MSHFlexGrid1.TextMatrix(i, j) = i & ", " & j '单元格的数值等于坐标值
Next j
Next i
MSHFlexGrid1.SelectionMode = flexSelectionByRow '设置MSHFlexGrid1的选择方式是按行选择
HaveSelected = False '设置标志,防止没选择就删除
End Sub
Private Sub MSHFlexGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
HaveSelected = True '设置标志允许删除
End Sub
Private Sub Command1_Click()
If HaveSelected = True Then MSHFlexGrid1.RemoveItem MSHFlexGrid1.RowSel '删除选中的行
End Sub
Private Sub Form_Load() '窗体加载的时候做的准备,一方面添加些数据,另一方面做些初始必须的设置与赋值,这就是初始化
MSHFlexGrid1.Cols = 10 '设置MSHFlexGrid1为十列
MSHFlexGrid1.Rows = 10 '设置MSHFlexGrid1为十行
MSHFlexGrid1.FixedCols = 0 '无固定列
MSHFlexGrid1.FixedRows = 0 '无固定行
For i = 0 To MSHFlexGrid1.Rows - 1 '从第一行到最后一行遍历循环,就跟数数一样
For j = 0 To MSHFlexGrid1.Cols - 1 '从第一列到最后一列遍历循环,就跟数数一样
MSHFlexGrid1.TextMatrix(i, j) = i & ", " & j '单元格的数值等于坐标值
Next j
Next i
MSHFlexGrid1.SelectionMode = flexSelectionByRow '设置MSHFlexGrid1的选择方式是按行选择
HaveSelected = False '设置标志,防止没选择就删除
End Sub
Private Sub MSHFlexGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
HaveSelected = True '设置标志允许删除
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询