設置鍵值調用它在Delphi 7出現TDBLookupControl的SetKeyValue:
procedure TDBLookupControl.SetKeyValue(const Value: Variant);
begin
if not VarEquals(FKeyValue, Value) then
begin
FKeyValue := Value;
KeyValueChanged;
end;
end;
procedure TDBLookupComboBox.KeyValueChanged;
begin
if FLookupMode then
begin
FText := FDataField.DisplayText;
FAlignment := FDataField.Alignment;
end else
if ListActive and LocateKey then
begin
FText := FListField.DisplayText;
FAlignment := FListField.Alignment;
end else
begin
FText := '';
FAlignment := taLeftJustify;
end;
Invalidate;
end;
正如你所看到的,你的變量x被用作LocateKey的一部分。
function TDBLookupControl.LocateKey: Boolean;
var
KeySave: Variant;
begin
Result := False;
try
KeySave := FKeyValue;
if not VarIsNull(FKeyValue) and FListLink.DataSet.Active and
FListLink.DataSet.Locate(FKeyFieldName, FKeyValue, []) then // << ---here
begin
Result := True;
FKeyValue := KeySave;
end;
except
end;
end;
進入這些程序和功能應該可以幫助您調試您的問題。所有位於DbCtrls單位..
ty約翰。沒有轉換。在字符串組合(比方說DBLookupComboBox1)我使用名稱,並在整數組合(讓我們說DBLookupComboBox2),我只使用身份證號碼)。 所以在DBLookupComboBox1我希望它是例如:阿姆斯特丹 和DBLookupComboBox2我希望它是例如:1500. 我將編輯我的問題 – 2015-01-31 19:58:46
我不應該說字符串轉換,編輯答案並刪除該引用。設置一個斷點並比較兩個值(將X作爲變體,將底層查找數據庫字段值作爲變體進行比較)。作爲另一個測試,將它們作爲字符串進行比較 – 2015-01-31 20:05:07
的事情是,當我調試,我可以看到我需要的號碼進入Keyvalue,但它只是不顯示它在屏幕上... – 2015-01-31 20:16:11