combobox3下拉框中的内容我是通过如下方法得到的,我在选择下拉框内容的时候,GchItemID和GchItemName都显示在combobox3的text中了,我想选择下拉框中内容的时候让combobox3的text中只显示GchItemID,请问如何实现? combobox3.Clear;
FenBaoGchl1.SQL.Clear;
FenBaoGchl1.SQL.Add('select distinct GchItemID,GchItemName from FenBaoGchl where FbID='+quotedstr(trim(combobox4.Text))+'and XMB='+quotedstr(trim(form23.Edit1.text))+'order by GchItemName asc ');
FenBaoGchl1.Prepared;
FenBaoGchl1.Open;
FenBaoGchl1.first;
while not FenBaoGchl1.Eof do
begin
combobox3.Items.Add(FenBaoGchl1.Fieldbyname('GchItemID').AsString+'——'+FenBaoGchl1.Fieldbyname('GchItemName').AsString);
FenBaoGchl1.Next;
end;
FenBaoGchl1.SQL.Clear;
FenBaoGchl1.SQL.Add('select distinct GchItemID,GchItemName from FenBaoGchl where FbID='+quotedstr(trim(combobox4.Text))+'and XMB='+quotedstr(trim(form23.Edit1.text))+'order by GchItemName asc ');
FenBaoGchl1.Prepared;
FenBaoGchl1.Open;
FenBaoGchl1.first;
while not FenBaoGchl1.Eof do
begin
combobox3.Items.Add(FenBaoGchl1.Fieldbyname('GchItemID').AsString+'——'+FenBaoGchl1.Fieldbyname('GchItemName').AsString);
FenBaoGchl1.Next;
end;
with ComboBox1 do
begin
Canvas.FillRect(Rect);
if odSelected in State then
begin
Canvas.Font.Color := clWhite;
Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, '你的ID值,可以根据Index这个参数从数据集中取');
end
else begin
Canvas.Font.Color := clBlack;
Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, Items[Index]);
end;
end;
怎么取啊?可以详细告诉我吗?
i := 0;
DataSet.First;
while i < Index do
DataSet.Next;
这样就定位到这条记录了。
begin
DataSet.Next;
Inc(i);
end;