Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello, I have created a program that makes a lot of buttons inside a panel that is inside a panel. The reason for a panel inside a panel is so the user can have an up/down button to scroll and see all the buttons.

 

My issue is with the down button.. knowing when to stop allowing the user to go down (making it so when the user scrolls down... he cannot keep scrolling past the last button...)

 

my buttons are space 151 pixels from the start of one button to the start of the next... and they are 4 wide (that is why i divide by 4 in the equation)..

 

 

Private Sub btnDown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDown.Click
       If TotalButtons / 4 * 151 > -(Me.ButtonPanel.Top * 2) Then
           MsgBox(TotalButtons / 4 * 151 & " " & Me.ButtonPanel.Top * 2)
           Me.ButtonPanel.Top = Me.ButtonPanel.Top - 151
       End If
   End Sub

 

 

The me.buttonpanel.top dimensions are static (like 3000x600 or something like that)...

 

 

thanks for any help!

Pigeon

Posted

Why not just do something like:

 

If buttonpanel.Top > -(buttonpanel.Height - 151) Then

'allow scrolling

End If

 

You shouldn't even need to worry about how many buttons there are, just the size of the panel that contains them.

Here's what I'm up to.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...