绑定滚动功能实现 [英] tied scroll function implementation

查看:86
本文介绍了绑定滚动功能实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

再见,

我在最近的趣味性/副项目中还有一个关于函数实现的问题.我在此处找到有关同步滚动列表框的文章

同步的ListBox对象(或如何滚动) 2个ListBox对象在一起) [

Hi again,

I have another question about function implementation on my recent fun/side project. I found an article on scrolling listboxes in sync here

Synchronized ListBox objects (or how to scroll 2 ListBox objects together)[^]

What I can''t discern is how to trigger events. I posted the top portion of code into a cs file (namespace i think), added 2 of the custom listboxes etc. That all went well.

I then proceeded to add the following functions to my form called Output.cs, which is an output form that contains the following modified listBox functions:

private void lstOutputNumbers_OnVerticalScroll(object sender, ScrollEventArgs e)
{
    MessageBox.Show("");
    lstOutput.TopIndex = lstOutputNumbers.TopIndex;
}

private void lstOutput_OnVerticalScroll(object sender, ScrollEventArgs e)
{
    MessageBox.Show("");
    lstOutputNumbers.TopIndex = lstOutput.TopIndex;
}



这是原始代码:



Here is the original Code:

private void syncListView2_OnVerticalScroll(object sender, ScrollEventArgs e)
{
    syncListView1.TopIndex = syncListView2.TopIndex;
}

private void syncListView1_OnVerticalScroll(object sender, ScrollEventArgs e)
{
    syncListView2.TopIndex = syncListView1.TopIndex;
}


我所做的唯一修改是对lstBox名称的修改. lstOutPutNumbers和lstOutput,以及添加的用于测试的消息框.但是,无论我如何滚动,都无法获得同步滚动,甚至无法显示消息框,告诉我该事件不是由滚动触发的.有人可以帮助我解决这个问题吗?

感谢以前来自该社区的帮助.希望你们也能帮助我解决这个问题.

〜Travis


The only modifications I made were to the lstBox names; lstOutPutNumbers, and lstOutput, as well as added messageboxes for testing. However, no matter how I scroll I am not able to get a synchronized scroll, or even messageboxes to appear which tells me the event is not being triggered by scrolling. Anyone able to help me puzzle through this?

Appreciate the previous help from this community. Hopefully you guys can help me tackle this one also.

~Travis

推荐答案

您实际上将这两种方法设置为事件处理程序吗?
Have you actually set the two methods as event handlers?


这篇关于绑定滚动功能实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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