Solved

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

Posted on 2006-07-01
7
284 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
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 14

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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 100 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 run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now