Click here to Skip to main content
15,909,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
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:
C#
private void syncListView2_OnVerticalScroll(object sender, ScrollEventArgs e)
{
    syncListView1.TopIndex = syncListView2.TopIndex;
}

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

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
Posted
Updated 4-Dec-11 22:31pm
v3

1 solution

Have you actually set the two methods as event handlers?
 
Share this answer
 
Comments
pirotrav 5-Dec-11 4:31am    
Possibly not. I am a bit new at c#. 3 yrs college experience, and that's about it. Event handling is not my expertise. I have understanding of scope, declaring variables, loops; programming basics at an intermediate level. Any chance you can elaborate/lead me down the right path?
pirotrav 5-Dec-11 4:36am    
If not i'll try and read up on events and so on in the morning. Thank you though; gets me in the right direction.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900