使用DATAGRID控件,现在想要单击一个按钮使滚动条向左或右移动如何实现?
注意:当DATAGRID控件上的焦点向上或向下移动时滚动条会随之移动,但焦点向左或向右移动时则滚动条不会随之移动!!!!
设置LeftCol属性可以滚动横向滚动跳
因为有汉字,所以焦点向左或向右移动时则滚动条不会随之移动!
只要:
DataGrid1.MarqueeStyle = dbgHighlightCell
焦点向左或向右移动时滚动条会随之移动
向右:
Private Sub Command1_Click()
If DataGrid1.LeftCol < DataGrid1.Columns.Count - 1 Then
DataGrid1.LeftCol = DataGrid1.LeftCol + 1
End If
End Sub
向左:
Private Sub Command2_Click()
If DataGrid1.LeftCol > 0 Then
DataGrid1.LeftCol = DataGrid1.LeftCol - 1
End If
End Sub