テキスト値が長いコンボボックスを使用しているアプリケーションで作業しています。テキスト値が大きいため(文字数..20以上)、コンボボックスに表示するには、first
を選択した後に文字に表示する必要がありました。ドロップダウンから。赤でマークされた画像のように。ユーザーが3番目の項目を選択した場合、コンボボックスに3 0.5 to 1.25 Slight
のみ表示する必要があります。3
だから私はこれを試しました
sTheSelectedValue : string;
procedure TForm1.ComboBox1Select(Sender: TObject);
begin
sTheSelectedValue:=TrimTextAndDisplay(ComboBox1.Text); //send theselected value
ComboBox1.Text :=''; //clear the selection
ComboBox1.Text:=sTheSelectedValue; //now assign as text to combo box
Button1.Caption:=ComboBox1.Text; //just show the new value on the button.
end;
function TForm1.TrimTextAndDisplay(TheText : string): string;
var
sTheResult : string;
begin
sTheResult :=copy(TheText,0,1); //extract the first value..
Result :=sTheResult;
end;
結果は
ボタンは適切な値を示しているように見えますが、コンボボックスは示していません。
私が欲しいのは3
コンボボックスに入ることです、私ComboBox1.Text:=
は誰もそれを行う方法を教えてもらえないようです?コンボボックスからの選択でこのように結果は次のようになります