I have a panel in witch I represent a timeline – 24 hours(24 x 60 min = 1 440 min).
I need to set my scroll bar’s step to a minute. It’s evident that minimum size of such a panel should be 1440 pixels.
Let’s say the screen resolution on the client screen (width) is 1280, so say panel container max size is 1280.
Now, if I want my step be a minute I need to set the step to the scrollbar’s container to 1280 / 1440 = 0.(8) – but it’s impossible, cause the Step (myContainer.HorizontalScroll.SmallChange) is an int value…
Can I do something to this?
EDIT
Maybe 0.2 pixel per minute can be considered a inobservable error, but if my step will be 5 minutes, it will in reality be 4.(4)px but in scrollbar = 5, a step of 10 minutes will be = 8.(8)px : 10px. On a 800×600 screen the 10min step will be = 5.(5)px : 10px, so in each 2 clicks(20 min) I have 4 pixel error. This “delta” became visible.
Finally, this is a sample, that DOES NOT work – even if I arrive to make the scrollbar visible – strange scrollbar visibility is unpredictable… – I can’t scroll all the VOLVO logo in 6 (60Maxim/10smallChange) steps…:
alt text http://lh6.ggpht.com/_1TPOP7DzY1E/S1eOPUlVvQI/AAAAAAAAC8M/ZFWDI_aaJxI/s800/panels.png
Designer:
this.panel2.BackgroundImage = ....Resources.volvo_logo;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
Code:
public partial class Form1 : Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
public Form1()
{
InitializeComponent();
panel1.AutoScroll = false;
panel1.HorizontalScroll.Maximum = 60;
panel1.HorizontalScroll.SmallChange = 10;
panel1.HorizontalScroll.LargeChange = 10;
panel1.HorizontalScroll.Visible = true;
panel1.Scroll += new ScrollEventHandler(panel1_Scroll);
}
void panel1_Scroll(object sender, ScrollEventArgs e)
{
Console.WriteLine(
"Scroll: OldVal {0}, NewVal {1}, Orientation {2}, Type {3}",
e.OldValue, e.NewValue, e.ScrollOrientation, e.Type);
}
}
Set the ClientSize in pixels (1440) and leave the small change = 1. It will also be in pixels and will match your minutes.