Dim mysort As Integer
Private Sub Form_Load()
With MSHFlexGrid1
.Cols = 4
.Rows = 20 '20行4列
For i = 0 To 79
.TextArray(i) = IIf(i < 4, Chr(i + 65), Format(Int(100 * Rnd), "00"))'随机赋值
Next
End With
mysort = 7' 升序
End Sub
Private Sub MSHFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
mysort = 15 - mysort '升序降序转换
With MSHFlexGrid1
If Button = 1 And .MouseRow = 0 Then '点击左键,第1 行
.Col = .MouseCol '选择排序列
.ColSel = 1
.Sort = mysort '排序方式
End If
End With
End Sub
MSHFlexGrid1使用技巧(二)[如何让MSHFlexGrid实现点击列标题排序]
最新推荐文章于 2024-04-09 14:52:11 发布
博客给出了一段代码,在Form_Load事件中对MSHFlexGrid1控件设置为20行4列,并随机赋值,初始排序为升序。在MSHFlexGrid1_MouseDown事件中,实现升序降序转换,当点击左键且在第1行时,可选择排序列并按指定方式排序。
2064

被折叠的 条评论
为什么被折叠?



