我正在处理一个应用程序,其中有一个长文本值的组合框。由于文本值很大(以字符..20或更多),要显示在组合框中,在从下拉列表中选择后显示在first
字符上。 就像用红色标记的图像一样。如果用户选择第3项3 0.5 to 1.25 Slight
,我应该只在组合框中显示3
。在选定的位置设置ComboBox文本
所以我想这
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
在ComboBox,我似乎无法设置ComboBox1.Text:=
任何一个可以告诉我怎么办呢? 这样从组合框中选择的结果应该是
G.E.N.I.U.S。有效 – PresleyDias