R
rgn
Unregistered / Unconfirmed
GUEST, unregistred user!
在程序运行期动态设置控件焦点顺序?listbox1里面能否改成中文名称呢?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
ListBox1: TListBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
procedure LoadComponent;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
LoadComponent;
end;
procedure TForm1.LoadComponent;
var
i:integer;
tl:TList;
tc:TWinControl;
begin
tl := TList.create;
try
self.GetTabOrderList(tl);
with ListBox1.Items do
begin
clear;
for i := 0 to tl.count - 1 do
begin
tc := TL;
if (tc is TWincontrol) and (tc.TabStop) then
AddObject(tc.Name,tc);
end;
end;
finally
tl.free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
with ListBox1, Items do
begin
if ItemIndex > 0 then
Exchange(ItemIndex,ItemIndex-1);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
with ListBox1, Items do
begin
if (ItemIndex >= 0) and (ItemIndex < count-1) then
Exchange(ItemIndex,ItemIndex+1);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
LoadComponent;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
i:integer;
tc:TWinControl;
begin
with ListBox1, Items do
for i := 0 to count - 1 do
begin
tc := TWinControl(objects);
if assigned(tc) then
tc.TabOrder := i;
end;
end;
end.
例如edit1在listbox1里面显示是'姓名',怎样改这个程序呢?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
ListBox1: TListBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
procedure LoadComponent;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
LoadComponent;
end;
procedure TForm1.LoadComponent;
var
i:integer;
tl:TList;
tc:TWinControl;
begin
tl := TList.create;
try
self.GetTabOrderList(tl);
with ListBox1.Items do
begin
clear;
for i := 0 to tl.count - 1 do
begin
tc := TL;
if (tc is TWincontrol) and (tc.TabStop) then
AddObject(tc.Name,tc);
end;
end;
finally
tl.free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
with ListBox1, Items do
begin
if ItemIndex > 0 then
Exchange(ItemIndex,ItemIndex-1);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
with ListBox1, Items do
begin
if (ItemIndex >= 0) and (ItemIndex < count-1) then
Exchange(ItemIndex,ItemIndex+1);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
LoadComponent;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
i:integer;
tc:TWinControl;
begin
with ListBox1, Items do
for i := 0 to count - 1 do
begin
tc := TWinControl(objects);
if assigned(tc) then
tc.TabOrder := i;
end;
end;
end.
例如edit1在listbox1里面显示是'姓名',怎样改这个程序呢?