请尝试以下代码,开是否能满足要求
VB- Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
- AddHandler Me.gcMultiRow.Scroll, AddressOf gcMultiRow_Scroll
- End Sub
- Dim changingDataSource As Boolean
- Private Sub gcMultiRow_Scroll(ByVal sender As Object, ByVal e As ScrollEventArgs)
- If changingDataSource Then
- e.NewValue = e.OldValue
- End If
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- changingDataSource = True
- gcMultiRow.DataSource = myDataSource
- changingDataSource = False
- End Sub
复制代码
C#- private void Form1_Load(object sender, EventArgs e)
- {
- this.gcMultiRow.Scroll += gcMultiRow_Scroll;
- }
- bool changingDataSource;
- private void gcMultiRow_Scroll(object sender, ScrollEventArgs e)
- {
- if (changingDataSource) {
- e.NewValue = e.OldValue;
- }
- }
- private void Button1_Click(System.Object sender, System.EventArgs e)
- {
- changingDataSource = true;
- gcMultiRow.DataSource = myDataSource;
- changingDataSource = false;
- }
复制代码 |