C#dotnetbar两个listboxadv同步滚动无法正常工作 [英] C# dotnetbar two listboxadv sync scroll not working

查看:455
本文介绍了C#dotnetbar两个listboxadv同步滚动无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个ListBoxAdv1和ListBoxAdv2,我希望同步它们滚动我使用此代码,只是向上或向下滚动但没有更新屏幕和另一个ListBoxAdv中的项目



我该怎么办?请帮助



我尝试了什么:



i试试这个:

i have two ListBoxAdv1 and ListBoxAdv2 and i want sync them scroll i used this code and just shown scrolled up or down but didn't update screen and items in another ListBoxAdv

what should i do? please help

What I have tried:

i try this:

private void listBoxAdv1_Scroll(object sender, ScrollEventArgs e)
{
       listBoxAdv2.VScrollBar.Value = listBoxAdv1.VScrollBar.Value;
}
private void listBoxAdv2_Scroll(object sender, ScrollEventArgs e)
{
      listBoxAdv1.VScrollBar.Value = listBoxAdv2.VScrollBar.Value;
}





这个:





and this:

private void listBoxAdv1_Scroll(object sender, ScrollEventArgs e)
{
               listBoxAdv2.Focus();
                   ScrollEventArgs scrollEventArgs = new ScrollEventArgs(ScrollEventType.SmallIncrement, e.OldValue, e.NewValue, ScrollOrientation.VerticalScroll);
                  listBoxAdv2_Scroll(listBoxAdv2, scrollEventArgs);
}
private void listBoxAdv2_Scroll(object sender, ScrollEventArgs e)
{
     
}

推荐答案

感谢您的回复!

i找到解决方案:



thanks for many response!
i find solution:

bool Scrolling = true;
       private void listBoxAdv1_Scroll(object sender, ScrollEventArgs e)
       {
           if (Scrolling == true)
           {
               Scrolling = false;
               listBoxAdv2.BeginUpdate();
               listBoxAdv2.AutoScrollPosition = new Point(listBoxAdv1.AutoScrollPosition.X, listBoxAdv1.AutoScrollPosition.Y);
               listBoxAdv2_Scroll(sender, e);
               listBoxAdv2.EndUpdate();
               Scrolling = true;
           }
       }

       private void listBoxAdv2_Scroll(object sender, ScrollEventArgs e)
       {
           if (Scrolling == true)
           {
               Scrolling = false;
               listBoxAdv1.BeginUpdate();
               listBoxAdv1.AutoScrollPosition = new Point(listBoxAdv2.AutoScrollPosition.X, listBoxAdv2.AutoScrollPosition.Y);
               listBoxAdv1_Scroll(sender, e);
               listBoxAdv1.EndUpdate();
               Scrolling = true;
           }
       }


这篇关于C#dotnetbar两个listboxadv同步滚动无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆