有以下代码:
with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select 职位 from worker-basic_info');
open;
first;
while not eof do
begin
CheckListBox1.Items.Add(ADOQuery1.fieldbyname('职位').AsString);
next;
end;
end;
能不能每当在CheckListBox中添加一个内容,就动态的在其后加一个edit组件,以便在起中填写基本工资?
with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select 职位 from worker-basic_info');
open;
first;
while not eof do
begin
CheckListBox1.Items.Add(ADOQuery1.fieldbyname('职位').AsString);
next;
end;
end;
能不能每当在CheckListBox中添加一个内容,就动态的在其后加一个edit组件,以便在起中填写基本工资?
tt: array of tedit;
i: integer;
begin
setlength(tt,RecordCount);
for i:=0 to RecordCount-1 do
begin
tt[i]:=Tedit.Create(self);
tt[i].Visible:=true;
tt[i].Text:=FieldByName('职位').AsString;
tt[i].Left:=10;
tt[i].Top:=i*20;
tt[i].Parent:=self;
end;
AEdit.Parent := self;
AEdit.Top := XXX;
AEdit.Left := YYY;
AEdit.Visible := True;
大概如此!!
设计思路不对!
...
with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select 职位,工资 from worker-basic_info');
open;
first;
while not eof do
begin
CheckListBox1.Items.Add(ADOQuery1.fieldbyname('职位').AsString);
//你要的
with TEdit.Create(self) do
begin
parent := Self;
left := CheckListBox1.left;
top := CheckListBox1.Top + 100;
Text := ADOQuery1.FieldbyName('工资').AsString);
end;
next;
end;
end;
我也想过静态生成,但是事先补知道用几个edit啊。
我想白格子上的内容让用户写,那里怎么是只读啊?
1、StringGrid的Options中goEditing=True;(IDE编辑窗口就可以设置)
2、Options的其他属性根据需要设置;
3、定义StringGrid1MouseMove消息的处理:
procedure TForm1.StringGrid1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
Grid1_X:=X;
Grid1_Y:=Y;
end;
其中Grid1_X、Grid1_Y可以在StringGrid1所在的Form中定义。
4、定义StringGrid1Click:
procedure TForm1.StringGrid1Click(Sender: TObject);
Var ACol,ARow: Integer;
begin
//根据鼠标位置计算Cell的行和列:
StringGrid1.MouseToCell(Grid1_X,Grid_Y,ACol,ARow); //其他处理。
end;
——可以,你在程序中可以直接赋值。
StringGrid1.Cells[0,0]:='kkkkkk';
StringGrid1.Cells[0,1]:='mmmmmm';