Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Scroll Buttons on a Panel Up and Down (Very Urgent)

Posted on 2006-07-01
7
Medium Priority
?
296 Views
Last Modified: 2010-04-05
Hello Experts,

  I have a Panel on which I need to place 20 buttons. I also have 2 buttons Up and Down. I will be able to view only 10 buttons on the Panel at a time. Now when I press the Up Button, I should be able to Scroll Up one button and similarly when I press Down I should be able to scroll Down one button. I am not supposed to use a Scroll Bar. I should be able to scroll using the Up and Down buttons only. Similarly I should be able to move Left and Right (Horizontal Scrolling). How will I be able to do this. Any ideas appreciated.

with regards,
padmaja.
0
Comment
Question by:saravananvg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Expert Comment

by:SergiuAdrian
ID: 17023552
how about moving al the bunttons <up> when you click the <up button> and <down> when pressing <down button>:

when press up:

for i:= 1 to buttonCount do
   button[i].top := button[i].top - ScrollDistance;

when press down (the only diference is you have to add the moving distance):

for i:= 1 to buttonCount do
   button[i].top := button[i].top + ScrollDistance;

if you make all buttons same size and the distance between button rows and edge/bottom of the pannel  is same you can find the ScrollDistance := TheHeightOfAButton + DistanceBetweenRows. this will make the first row disapear when click up and the last row disapear when click down.

i sugest also to verify when all rows will be invisible if click up or down. this means you have scroll to much up or to much down. but this is optional ;)
0
 
LVL 15

Expert Comment

by:Hamidreza Vakilian
ID: 17023807
Hi!

It's very simple...

assume that P1 is the main panel that you have to scroll within it. you can easily put another Panel in P1 & put your buttons on the second panel...

For scrolling you can change TOP & LEFT properties of the second panel....
Also these properties accept negative values....

Programmer-x
0
 

Expert Comment

by:SergiuAdrian
ID: 17024253
yes, if you use only 2 rows of buttons this is a good idea.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Expert Comment

by:SergiuAdrian
ID: 17024256
or if use more rows also you can make a panel for each row an move all panels at the same time.
0
 
LVL 4

Expert Comment

by:kenpem
ID: 17026935
or split the buttons between two panels which appear in the same place on the form. Then as Up/Down is pushed, set Panel1.Visible, etc.
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 300 total points
ID: 17030945
No, you need to put a TStrollBox on your panel and make it alLeft aligned. Drop your
buttons on top of the TStcrollBox and your "scroll" buttons on the right
and everything should take care of itself.


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    ScrollBox1: TScrollBox;
    btnUp: TButton;
    btnDown: TButton;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    Button10: TButton;
    Button11: TButton;
    Button12: TButton;
    Button13: TButton;
    Button14: TButton;
    Button15: TButton;
    Button16: TButton;
    Button17: TButton;
    Button18: TButton;
    Button19: TButton;
    Button20: TButton;
    procedure btnUpClick(Sender: TObject);
    procedure btnDownClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btnUpClick(Sender: TObject);
begin
  if Button1.Top < 0 then
    ScrollBox1.ScrollBy(0, ScrollBox1.Height);
end;

procedure TForm1.btnDownClick(Sender: TObject);
begin
  if Button1.Top >= 0 then
    ScrollBox1.ScrollBy(0, -ScrollBox1.Height);
end;

end.


DFM Source:
object Form1: TForm1
  Left = 282
  Top = 62
  Width = 696
  Height = 483
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 642
    Height = 449
    Align = alLeft
    BevelOuter = bvNone
    Caption = 'Panel1'
    TabOrder = 0
    object Panel2: TPanel
      Left = 529
      Top = 0
      Width = 113
      Height = 449
      Align = alRight
      BevelOuter = bvNone
      TabOrder = 0
      object btnUp: TButton
        Left = 11
        Top = 35
        Width = 75
        Height = 25
        Caption = 'Up'
        TabOrder = 0
        OnClick = btnUpClick
      end
      object btnDown: TButton
        Left = 11
        Top = 60
        Width = 75
        Height = 25
        Caption = 'Down'
        TabOrder = 1
        OnClick = btnDownClick
      end
    end
    object Panel3: TPanel
      Left = 0
      Top = 0
      Width = 529
      Height = 449
      Align = alClient
      BevelOuter = bvNone
      Caption = 'Panel3'
      TabOrder = 1
      object ScrollBox1: TScrollBox
        Left = 0
        Top = 0
        Width = 529
        Height = 449
        HorzScrollBar.Visible = False
        VertScrollBar.Visible = False
        Align = alClient
        BevelInner = bvNone
        BevelOuter = bvNone
        TabOrder = 0
        object Button1: TButton
          Left = 0
          Top = 0
          Width = 105
          Height = 223
          Caption = 'Button1'
          TabOrder = 0
        end
        object Button2: TButton
          Left = 105
          Top = 0
          Width = 105
          Height = 223
          Caption = 'Button2'
          TabOrder = 1
        end
        object Button3: TButton
          Left = 210
          Top = 0
          Width = 105
          Height = 223
          Caption = 'Button3'
          TabOrder = 2
        end
        object Button4: TButton
          Left = 315
          Top = 0
          Width = 105
          Height = 223
          Caption = 'Button4'
          TabOrder = 3
        end
        object Button5: TButton
          Left = 420
          Top = 0
          Width = 105
          Height = 223
          Caption = 'Button5'
          TabOrder = 4
        end
        object Button6: TButton
          Left = 0
          Top = 223
          Width = 105
          Height = 223
          Caption = 'Button6'
          TabOrder = 5
        end
        object Button7: TButton
          Left = 105
          Top = 223
          Width = 105
          Height = 223
          Caption = 'Button7'
          TabOrder = 6
        end
        object Button8: TButton
          Left = 210
          Top = 223
          Width = 105
          Height = 223
          Caption = 'Button8'
          TabOrder = 7
        end
        object Button9: TButton
          Left = 315
          Top = 223
          Width = 105
          Height = 223
          Caption = 'Button9'
          TabOrder = 8
        end
        object Button10: TButton
          Left = 420
          Top = 223
          Width = 105
          Height = 223
          Caption = 'Button10'
          TabOrder = 9
        end
        object Button11: TButton
          Left = 0
          Top = 446
          Width = 105
          Height = 223
          Caption = 'Button11'
          TabOrder = 10
        end
        object Button16: TButton
          Left = 0
          Top = 670
          Width = 105
          Height = 223
          Caption = 'Button16'
          TabOrder = 11
        end
        object Button17: TButton
          Left = 105
          Top = 670
          Width = 105
          Height = 223
          Caption = 'Button17'
          TabOrder = 12
        end
        object Button12: TButton
          Left = 105
          Top = 447
          Width = 105
          Height = 223
          Caption = 'Button12'
          TabOrder = 13
        end
        object Button13: TButton
          Left = 210
          Top = 447
          Width = 105
          Height = 223
          Caption = 'Button13'
          TabOrder = 14
        end
        object Button18: TButton
          Left = 210
          Top = 670
          Width = 105
          Height = 223
          Caption = 'Button18'
          TabOrder = 15
        end
        object Button19: TButton
          Left = 315
          Top = 670
          Width = 105
          Height = 223
          Caption = 'Button19'
          TabOrder = 16
        end
        object Button14: TButton
          Left = 315
          Top = 447
          Width = 105
          Height = 223
          Caption = 'Button14'
          TabOrder = 17
        end
        object Button15: TButton
          Left = 420
          Top = 447
          Width = 105
          Height = 223
          Caption = 'Button15'
          TabOrder = 18
        end
        object Button20: TButton
          Left = 420
          Top = 670
          Width = 105
          Height = 223
          Caption = 'Button20'
          TabOrder = 19
        end
      end
    end
  end
end

0
 
LVL 6

Author Comment

by:saravananvg
ID: 17034990
Hello Experts,

  Thanks for your suggesstions, I shall work on them and get back to you very soon.

with regards,
padmaja.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question