Newbie problem - AutoScrollPosition 
Author Message
 Newbie problem - AutoScrollPosition

I need a scrollable child window to display some computed graphics
(Not GIF, JPG, etc.) built from 2D drawing primitives.  It seems
like ScrollableControl or Panel should be able to do what I want.
In fact, I can make them work perfectly for mouse operation, but
I also want to be able to oeprate the scrollers using keystrokes.
That is where the problem starts.  I have done a test subclass
from ScrollableControl, and a simple override handler for the
KeyDown event.  (Would prefer the KeyPress event, but don't see
how to detect the cursor keys.)  In any case, the problem is
that the property write back to AutoScrollPosition just doesn't
seem to work.  The two Console writes at the end show that
point has been changed, but AutoScrollPosition remains unchanged.
The writeback doesn't take.  It acts like it is readonly.

Imports System.Drawing
Imports System.Windows.Forms
Public Class ScrollableDisplay
     Inherits System.Windows.Forms.ScrollableControl

     Private Sub ScrollableDisplay_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
         Dim point As Point = AutoScrollPosition

         Console.WriteLine("AP = {0},{1}", _
             AutoScrollPosition.X, AutoScrollPosition.Y)

         If e.KeyData = Keys.End Then
             e.Handled = True
             point.Y = -50
             AutoScrollPosition = point
         End If

         Console.WriteLine("pt = {0},{1}", point.X, point.Y)
         Console.WriteLine("AP = {0},{1}", _
             AutoScrollPosition.X, AutoScrollPosition.Y)
     End Sub
End Class

Actually, I would have thought that there would be a way to connect
the keystrokes directly in the ScrollableControl class, but couldn't
find a way to do it.

Any idea what I am doing wrong?

Am I doing anything that is reasonable?

Should I call the base class in my override?



Sun, 06 Mar 2005 02:00:05 GMT  
 Newbie problem - AutoScrollPosition

Quote:

> I need a scrollable child window to display some computed graphics
> (Not GIF, JPG, etc.) built from 2D drawing primitives.  It seems
> like ScrollableControl or Panel should be able to do what I want.
> In fact, I can make them work perfectly for mouse operation, but
> I also want to be able to oeprate the scrollers using keystrokes.
> That is where the problem starts.  I have done a test subclass
> from ScrollableControl, and a simple override handler for the
> KeyDown event.  (Would prefer the KeyPress event, but don't see
> how to detect the cursor keys.)  In any case, the problem is
> that the property write back to AutoScrollPosition just doesn't
> seem to work.  The two Console writes at the end show that
> point has been changed, but AutoScrollPosition remains unchanged.
> The writeback doesn't take.  It acts like it is readonly.

On further research, it appears that the AutoScrollPosition property
elements X and Y are multiplied by -1 when you SET, but are returned
unchanged on a GET, so that a GET followed immediately by a SET fails
because the values (if nonzero) are out of range.  If I am right, this
should be a bug, but it doesn't make much sense.

Can anyone confirm this?

Is there a way to execute into the base class property methods, or to
see the source actual code of the relevant base class?



Sun, 06 Mar 2005 05:43:28 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. autoscrollposition doesn't "stick"

2. ***NEWBIE ALERT***NEWBIE ALERT***NEWBIE ALERT***

3. Newbie, problem with KeyPressed event

4. Newbie, secured database DAO connection problem

5. newbie: Database problem

6. newbie: Database problem

7. Newbie combobox problems

8. Newbie - Basic Code Problem

9. Newbie, with problem converting data

10. Having some problems with ObjectNames(newbie)

11. Newbie: help on two code-related problem

12. Newbie Toolbox problem

 

 
Powered by phpBB® Forum Software