AutoScroll not working
-
I have created graphics on a tabpage but cannot get its autoscroll working at all. Graphics g = tabPage1.CreateGraphics(); g.DrawString("Hello how are you?", new Font("Courier New", 10, System.Drawing.FontStyle.Regular), new SolidBrush(Color.Black), 10, 20); tabPage1.AutoScroll = true; Anybody know how to fix this problem?
-
I have created graphics on a tabpage but cannot get its autoscroll working at all. Graphics g = tabPage1.CreateGraphics(); g.DrawString("Hello how are you?", new Font("Courier New", 10, System.Drawing.FontStyle.Regular), new SolidBrush(Color.Black), 10, 20); tabPage1.AutoScroll = true; Anybody know how to fix this problem?
AutoScroll is concerned with the location/size of child controls. Rendering a string onto a tabpage has no effect on the logical visible area required to show all child controls, so the autoscrolling is unaffected. I suppose that you could add a Label to the tabpage, set it's Text to the string you are drawing, and position the Label such that it is outside of the currently visible area of the tabpage. Josh
-
I have created graphics on a tabpage but cannot get its autoscroll working at all. Graphics g = tabPage1.CreateGraphics(); g.DrawString("Hello how are you?", new Font("Courier New", 10, System.Drawing.FontStyle.Regular), new SolidBrush(Color.Black), 10, 20); tabPage1.AutoScroll = true; Anybody know how to fix this problem?
No, you have drawn something on the screen where the tabpage happens to be. Whatever you do to the tabpage won't affect what you drew. Actually, anything that makes the tabpage redraw will draw over what you drew. If you want to draw something on the control, you have to use it's Paint event, so that whatever you draw will be redrawn when the control is redrawn. --- b { font-weight: normal; }
-
AutoScroll is concerned with the location/size of child controls. Rendering a string onto a tabpage has no effect on the logical visible area required to show all child controls, so the autoscrolling is unaffected. I suppose that you could add a Label to the tabpage, set it's Text to the string you are drawing, and position the Label such that it is outside of the currently visible area of the tabpage. Josh
Thanks. But it doesn't seem to allow using both label and graphics on the same tabpage !? I used labels before but the display time was very very slow. So I changed to use graphics which can be displayed much much faster. I tried adding a label right after the last graphic object which should be outside of the currently visible area of the tabpage. However, all the graphic objects just blink & disappeared.
-
No, you have drawn something on the screen where the tabpage happens to be. Whatever you do to the tabpage won't affect what you drew. Actually, anything that makes the tabpage redraw will draw over what you drew. If you want to draw something on the control, you have to use it's Paint event, so that whatever you draw will be redrawn when the control is redrawn. --- b { font-weight: normal; }
How do I use paint event? When will the paint event be triggered? I need to write different text on a tabpage line by line. Can the paint event draw different strings to a control? Please help!!! I need a solution to it.