mshflexgrid控件點(diǎn)擊時(shí)可以選中多行,但有時(shí)我們需要僅僅選中一行,有一個(gè)小技巧:
option explicit
dim currentrow as integer
private sub form_load()
dim i as integer, j as integer
with mshflexgrid1
.rows = 10
.cols = 4
for i = 1 to 9
.textmatrix(i, 0) = "第 " & i & " 行"
for j = 1 to 3
.textmatrix(0, j) = "第 " & j & " 列"
.textmatrix(i, j) = i & "," & j
next
next
end with
end sub
private sub mshflexgrid1_mousedown(button as integer, shift as integer, x as single, y as single)
with mshflexgrid1
.row = .mouserow
currentrow = .row
.col = 0
.colsel = .cols - 1
end with
end sub
private sub mshflexgrid1_mouseup(button as integer, shift as integer, x as single, y as single)
with mshflexgrid1
.rowsel = currentrow
.colsel = .cols - 1
end with
end sub