unit WinForm;
interface
uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data;
type
TWinForm = class(System.Windows.Forms.Form)
{$REGION 'Designer Managed Code'}
strict private
///
/// Required designer variable.
///
Components: System.ComponentModel.Container;
ListBox1: System.Windows.Forms.ListBox;
ListBox2: System.Windows.Forms.ListBox;
Button1: System.Windows.Forms.Button;
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
procedure InitializeComponent;
procedure Button1_Click(sender: System.Object; e: System.EventArgs);
procedure TWinForm_Load(sender: System.Object; e: System.EventArgs);
{$ENDREGION}
strict protected
///
/// Clean up any resources being used.
///
procedure Dispose(Disposing: Boolean); override;
private
{ Private Declarations }
public
constructor Create;
end;
[assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]
implementation
{$AUTOBOX ON}
{$REGION 'Windows Form Designer generated code'}
///
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
///
procedure TWinForm.InitializeComponent;
begin
Self.ListBox1 := System.Windows.Forms.ListBox.Create;
Self.ListBox2 := System.Windows.Forms.ListBox.Create;
Self.Button1 := System.Windows.Forms.Button.Create;
Self.SuspendLayout;
//
// ListBox1
//
Self.ListBox1.Font := System.Drawing.Font.Create('Microsoft Sans Serif', 12,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (Byte(0)));
Self.ListBox1.ItemHeight := 20;
Self.ListBox1.Location := System.Drawing.Point.Create(32, 24);
Self.ListBox1.Name := 'ListBox1';
Self.ListBox1.Size := System.Drawing.Size.Create(88, 124);
Self.ListBox1.TabIndex := 0;
//
// ListBox2
//
Self.ListBox2.Font := System.Drawing.Font.Create('Microsoft Sans Serif', 12,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (Byte(0)));
Self.ListBox2.ItemHeight := 20;
Self.ListBox2.Location := System.Drawing.Point.Create(176, 24);
Self.ListBox2.Name := 'ListBox2';
Self.ListBox2.Size := System.Drawing.Size.Create(88, 124);
Self.ListBox2.TabIndex := 1;
//
// Button1
//
Self.Button1.Font := System.Drawing.Font.Create('Microsoft Sans Serif', 12,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (Byte(0)));
Self.Button1.Location := System.Drawing.Point.Create(96, 184);
Self.Button1.Name := 'Button1';
Self.Button1.Size := System.Drawing.Size.Create(112, 32);
Self.Button1.TabIndex := 2;
Self.Button1.Text := '&Sort';
Include(Self.Button1.Click, Self.Button1_Click);
//
// TWinForm
//
Self.AutoScaleBaseSize := System.Drawing.Size.Create(5, 13);
Self.ClientSize := System.Drawing.Size.Create(292, 259);
Self.Controls.Add(Self.Button1);
Self.Controls.Add(Self.ListBox2);
Self.Controls.Add(Self.ListBox1);
Self.FormBorderStyle := System.Windows.Forms.FormBorderStyle.Fixed3D;
Self.MaximizeBox := False;
Self.Name := 'TWinForm';
Self.Text := ' Bubble Sort';
Include(Self.Load, Self.TWinForm_Load);
Self.ResumeLayout(False);
end;
{$ENDREGION}
procedure TWinForm.Dispose(Disposing: Boolean);
begin
if Disposing then
begin
if Components <> nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
constructor TWinForm.Create;
begin
inherited Create;
//
// Required for Windows Form Designer support
//
InitializeComponent;
//
// TODO: Add any constructor code after InitializeComponent call
//
end;
procedure TWinForm.TWinForm_Load(sender: System.Object; e: System.EventArgs);
var
i : integer;
const
list : array [0..5] of integer=(25,123,52,86,12,45);
begin
for i := 0 to 5 do
self.ListBox1.Items.Add(list[i]);
end;
procedure TWinForm.Button1_Click(sender: System.Object; e: System.EventArgs);
var
i,j,temp : integer;
A : array [0..5] of integer;
const
list : array [0..5] of integer=(25,123,52,86,12,45);
begin
self.ListBox2.Items.Clear;
for i := 0 to 5 do
A[i] := list[i];
for i := 0 to 4 do
for j := i+1 to 5 do
if A[i] < A[j] then
begin
temp := A[i];
A[i] := A[j];
A[j] := temp;
end;
for i := 0 to 5 do
self.ListBox2.Items.Add(A[i]);
end;
end.