Click here to Skip to main content
14,734,606 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:

I use a trackbar to select a certain image out of a list of images.
This works fine so far. But as there are many images it is impossible to get the correct immage just by scrolling. The sensitivity is too poor.
In a pictureBox I show the selected image using the trackbar value as index to get the path to the image file from the list of images.

To do the fine adjustment I added a Plus 1 and a Minus 1 button to step one by one through the list entries.

But now I have a problem, I want the trackbar to show the adjusted position.

Question: is that possible. I have not found a method nor a property that adjusts teh trackbar position. Value just gives you the actual value but does not change the bar. And what TabIndex does ist not clear to me.
The lines commented out in the short example below both do not yield the desired effect.

private void btnEM1_Click(object sender, EventArgs e)
    actEnd = actEnd - 1;
    if ((actEnd < numberFiles) && (actEnd > -1))
        txtBxStartFrame.Text = fileListS[actEnd];
        showFrame(actEnd, true);
        actEnd = 0;
    // trackBarEnd.TabIndex = actEnd;   this does not work
    // trackBarEnd.Value = actEnd;    and this does not work either.

Many thanks in advance for any hint.

Try this:

trackBarEnd.Value = actEnd;
Ed Nutting 2-Mar-12 15:34pm
Assuming it works (which given your status it probably does!), my 5+ - a solution though I think OP would be wise to use ListView for display image lists. Anyway, good solution :)
Wolfgang Kurz 3-Mar-12 2:18am
Hello John,
I am sorry, it does not work. The scroll position is not updated when stepping through the list. I will have to look at ListView.

Anyway many thanks for giving a hint
Well TabIndex will never help you - look at MSDN: MSDN Tab Index - Tab index is what order controls are selected in when the user uses the tab key to jump through controls on your form. As for Value, it should change the TrackBar (assuming you mean ScrollBar control?) to the desired position. I have not found a problem with this whenever I have used it. However, have you considered using a ListView which will display images as list items - it is far better than trying to write your own and has everything that you want. This page may help you out: MSDN - About the List View Control[^]

Hope this helps,
Wolfgang Kurz 3-Mar-12 2:18am
Hello Ed,
I will give ListView a try. But I am not very hopefull, that this might be the solution. In my case I must select a start image and an end image from a list of thousands of images created by my program MovieExtractor. This program uses a flatbed scanner to scan 35 mm movies in strips of about 18 cm (about 9 frames). From these strips the images and the light sound track are extracted in order to finally create a video using ffmpg.
And such a movie piece (e.g. a trailer of a blockbuster as published by entertainment companies for advertisment) might have up to 10 000 images.

If you are interested in details, you can look at
which is primaryly about CineFilms. But this is in principle the same process.

Many thanks for the hint

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