I am working on an application where i have a combobox with long text values.Since the text values are large(in term of characters ..20 or more), to display in the combobox, the requirement was to display on the first
character after selecting from the drop down.
Like in the image marked in red. if the user selects 3th item 3 0.5 to 1.25 Slight
i should only display the 3
in the combobox.
So i tried this
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;
The result is
The button seem to show the proper value but not the combobox.
what i want is to get 3
in the combobox, i cant seem set ComboBox1.Text:=
can any one tell me how to do it?
like this on selection of from the combobox the result should be