下面是我的程序,请帮忙看一下,先谢了(注,我用的是dev的cxComboBox,应该一样)
////form初始化,设置combobox的值
procedure TOperationDemoBaseFrame.FrameInitialization(bjlx : integer);
var
i : integer;
str : string;
procedure GetListValueOfString(sql : string
temp : TcxComboBox);
var
oratempqry : TOraQuery;
Pjgbm : Pint64
/////////这里是后改的
begin
oratempqry := TOraQuery.Create(nil);
try
new(Pjgbm);/////这里也是
oratempqry.Session := DMPolice.OraSession;
oratempqry.Close;
oratempqry.SQL.Text := sql;
oratempqry.Open;
if Not oratempqry.IsEmpty then
begin
while Not oratempqry.Eof do
begin
Pjgbm^ := oratempQry.FieldByName('a').asinteger;///这里也是
temp.Properties.Items.AddObject(oratempqry.fieldbyname('b').AsString,Tobject(Pjgbm));///这里也是
oratempqry.Next;
end;
end;
finally
oratempqry.Free;
end;
end;
begin
DMPolice.IsFrameFieldChange := False;
for i := 0 to self.ControlCount - 1 do
begin
if self.Controls is TcxComboBox then
begin
case TcxComboBox(self.Controls).Tag of
4 : begin
case bjlx of
0 : str := 'select jgbm a,jgmc b from zzjgdmb where jglx = 0 and dwlbdm in(1) and xs=1 order by px';
1 : str := 'select jgbm a,jgmc b from zzjgdmb where jglx = 1 and dwlbdm in(1,5) and xs=1 order by px';
2 : str := 'select jgbm a,jgmc b from zzjgdmb where jglx = 2 and dwlbdm in(1,3) and xs=1 order by px';
end;
TcxComboBox(self.Controls).Properties.Items.Clear;
GetListValueofString(str,TcxComboBox(self.Controls));////这里调用
TcxComboBox(self.Controls).Properties.OnChange := self.FrameFieldOnChange;
end;
end;
end;
end;
end;
/////保存方法,从combobox中取出值来
Function TOperationDemoBaseFrame.FrameSaveAll(AControl: TWinControl) : string;
var
i : integer;
temp : int64;
str : string;
begin
for i := 0 to AControl.ControlCount - 1 do
begin
case TwinControl(AControl.Controls).Tag of
1 : begin
if TcxComboBox(AControl.Controls).Text = '' then
str := str + 'bjlbdm = null,'
else
str := str + 'bjlbdm = ' + inttostr(integer(TcxComboBox(AControl.Controls).Properties.items.Objects[TcxComboBox(AControl.Controls).ItemIndex])) + ',';
end;
2 : begin
if TcxComboBox(AControl.Controls).Text = '' then
str := str + 'bjlxdm = null,'
else
str := str + 'bjlxdm = ' + inttostr(integer(TcxComboBox(AControl.Controls).Properties.items.Objects[TcxComboBox(AControl.Controls).ItemIndex])) + ',';
end;
3 : begin
if TcxComboBox(AControl.Controls).Text = '' then
str := str + 'bjxldm = null,'
else
str := str + 'bjxldm = ' + inttostr(integer(TcxComboBox(AControl.Controls).Properties.items.Objects[TcxComboBox(AControl.Controls).ItemIndex])) + ',';
end;
4 : begin//////////就是这里
if TcxComboBox(AControl.Controls).Text = '' then
str := str + 'gxdwdm = null,'
else
temp := Pint64(TcxComboBox(AControl.Controls).Properties.Items.Objects[TcxComboBox(AControl.Controls).ItemIndex])^;
str := str + 'gxdwdm = ' + inttostr(temp) + ',';
end;
5 : begin
if TcxComboBox(AControl.Controls).Text = '' then
str := str + 'jqjb = null,'
else
str := str + 'jqjb = ' + inttostr(integer(TcxComboBox(AControl.Controls).Properties.items.Objects[TcxComboBox(AControl.Controls).ItemIndex])) + ',';
end;
20 : begin
if trim(TcxTextEdit(AControl.Controls).Text) = '' then
str := str + 'afdd = null,'
else
str := str + 'afdd = ''' + trim(TcxTextEdit(AControl.Controls).text) + ''',';
end;
30 : begin
if trim(TcxTextEdit(AControl.Controls).Text) = '' then
str := str + 'bt = null,'
else
str := str + 'bt = ''' + trim(TcxTextEdit(AControl.Controls).text) + ''',';
end;
40 : begin
if trim(TcxTextEdit(AControl.Controls).Text) = '' then
str := str + 'bjnr = null,'
else
str := str + 'bjnr = ''' + trim(TcxTextEdit(AControl.Controls).text) + ''',';
end;
end;
end;
result := str;
end;