AutoScrollPosition property setter didn't take the value  
Author Message
Khammonh





PostPosted: Visual Basic General, AutoScrollPosition property setter didn't take the value Top

Hello All who interest to share idea.

I gone through the history of the question posted , here I see that the answer to them where has mentioned that I works, I try accordingly but it doesn't work. The issue is , what ever value ( positive or negative value ) we set for this property it doesn't take ,it always has value of empty point {0,0} says I set the value as bellow

Me.AutoScrollPosition=new point( 100,200)

or

Me.AutoScrollPosition=new point( -100,-200)

when I trace the value of me.AutoScrollPosition during debug I always get x=0 and y=0 or in another word empty point indeed its Empty property is True. Many guys asking for the answer for this but I didn't see any of them is a real working answer. I don't know why it doesn't work , if this not take value why Microsoft don't declare it as ReadOnly property. If we can't set its position through the property then through which mean we can set it value. Who know let me know but don't advise in the same manner that I saw in the over 60 posted answers , all of them don't work .

Regards



Visual Basic9  
 
 
nobugz





PostPosted: Visual Basic General, AutoScrollPosition property setter didn't take the value Top

The AutoScrollPosition property automatically clips the assigned value to a valid setting. That is only ever not (0, 0) if scrollbar(s) are actually shown. If they are shown, you'll have to use a negative value to scroll the controls to the left or top.



 
 
Khammonh





PostPosted: Visual Basic General, AutoScrollPosition property setter didn't take the value Top

Thank you Nobugz for your reply , but what is the definition of "Valid setting" and how we could programmaticaly set a so called "Valid setting" . My point is , I couldn't do a Zoom Window if I couldn't set Autoscrollposition on my Drawing surface which inherits from Panel.

The result of that is two scroll bars are always position at top left corner of drawing surface dispite of whereever I set the starting my zoom rectangle position. You have any suggestion

Regards


 
 
nobugz





PostPosted: Visual Basic General, AutoScrollPosition property setter didn't take the value Top

Please forget my statement about having to use negative values in my previous post. This code scrolls a panel to the far bottom-right corner:

private void button1_Click(object sender, EventArgs e) {
panel1.AutoScrollPosition = new Point(
panel1.AutoScrollMinSize.Width - panel1.ClientSize.Width,
panel1.AutoScrollMinSize.Height - panel1.ClientSize.Height);
}

So a valid setting for AutoScrollPosition.X = 0 .. (AutoScrollMinSize.Width - ClientSize.Width). Similar for Y.


 
 
Khammonh





PostPosted: Visual Basic General, AutoScrollPosition property setter didn't take the value Top

Hi

Sorry, I stuck with other project don't have time to look at your answer. Thank to reply me.

I did in the same manner you described above , at the first run it seam to work fine but at the next run it again go back to the state of what I face with before ( the set value is not taken and AutoScrollPosition always has x=0 and y=0) the different between each run is only zoom scale bellow is code of sub ZoomWindow

Private Sub ZoomWindow(ByVal ZoomRectangle As Rectangle)

Dim ZoomX, ZoomY As Single

Me.LasZoom = Me.Zoom

ZoomX = Me.Size.Width / ZoomRectangle.Width

ZoomY = Me.Size.Height / ZoomRectangle.Height

Me.Zoom = Min(ZoomX, ZoomY)

Me.AutoScrollMinSize = ZoomRectangle.Size

Dim PosX, PosY As Integer

PosX = Me.AutoScrollMinSize.Width - Me.ClientSize.Width

PosY = Me.AutoScrollMinSize.Height - Me.ClientSize.Height

Me.AutoScrollPosition = New Point(CType(PosX * Me.Zoom, Integer), CType(PosY * Me.Zoom, Integer))

End Sub

Sub in Visual Basic is the same as void type function C# it return nothing , hope you understand the syntax of Visual Basic I don't want to rewrite it in C# syntax.

Regards


 
 
noname0000000





PostPosted: Visual Basic General, AutoScrollPosition property setter didn't take the value Top

Please check on MSDN on AutoScrollPosition property:

it says when get you get negative values, when set you give positives

don't know why.