Panel scrolling
-
Hi. I want to plot the spectral diagram of a wav file onto a panel, which can be pretty long(the graph). The panel has a limited length, say 400 px. How can I add scroll bars to the Panel, so I can scroll back and forth to see the entire graph? I know that the Panel has a property called Autoscroll, automatically adds H&V scroll bars if there are controls outside the visible area. But nothing similar happens if I programatically draw something outside the panel's client area. Any ideas or suggestions? Thanks.
-
Hi. I want to plot the spectral diagram of a wav file onto a panel, which can be pretty long(the graph). The panel has a limited length, say 400 px. How can I add scroll bars to the Panel, so I can scroll back and forth to see the entire graph? I know that the Panel has a property called Autoscroll, automatically adds H&V scroll bars if there are controls outside the visible area. But nothing similar happens if I programatically draw something outside the panel's client area. Any ideas or suggestions? Thanks.
Hi Use DIV section instead of panel. Add your diagram section inside DIV Section and you can set the size for width and height; add the style as OVERFLOW: auto; Hope this solves your problem.
Harini
-
Hi Use DIV section instead of panel. Add your diagram section inside DIV Section and you can set the size for width and height; add the style as OVERFLOW: auto; Hope this solves your problem.
Harini
I forgot to mention that this is a Windows application, not a web site. Thanks anyway.
-
I forgot to mention that this is a Windows application, not a web site. Thanks anyway.
Put a picture box control in a panel and set its SizeMode property to AutoSize and then set AutoScroll property of Panel to True. Now draw your chart on Picture box instead of Panel. However the most important point is that, in this scenario you will need to reset the width of Picture box according to the increasing size of Graph. Therefore you will have to measure the width of the drawn area and reset width of Picture Box. Following is a small code snippet which I used to test, it draws a long string on a Picturebox and Panel will show scroll bar as expected.- ------------------Code Start------------------------------------------------------ private void PictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Graphics g = e.Graphics; string str = "JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmJJJJJJJJJJJ"; g.DrawString(str, new Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Pixel), Brushes.Black, 50, 50); this.PictureBox1.Width = g.MeasureString(str, new Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Pixel)).Width + 4; } -------------Code End-------------------------------------- I hope this will help you in finding the exact resolution. -Dave.
Dave Traister, ComponentOne LLC. www.componentone.com
-
Put a picture box control in a panel and set its SizeMode property to AutoSize and then set AutoScroll property of Panel to True. Now draw your chart on Picture box instead of Panel. However the most important point is that, in this scenario you will need to reset the width of Picture box according to the increasing size of Graph. Therefore you will have to measure the width of the drawn area and reset width of Picture Box. Following is a small code snippet which I used to test, it draws a long string on a Picturebox and Panel will show scroll bar as expected.- ------------------Code Start------------------------------------------------------ private void PictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Graphics g = e.Graphics; string str = "JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmJJJJJJJJJJJ"; g.DrawString(str, new Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Pixel), Brushes.Black, 50, 50); this.PictureBox1.Width = g.MeasureString(str, new Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Pixel)).Width + 4; } -------------Code End-------------------------------------- I hope this will help you in finding the exact resolution. -Dave.
Dave Traister, ComponentOne LLC. www.componentone.com
Thank you! You saved my day and got my 5.