petershaw9
asked on
Display on the ComboBox
In the Combobox Item, It has items, like 'SBW Seacon Bonded Warehouse ', all lines start with 3 characters.
When I select it, I wish the box shows the first 3 characters only. How can do this?
Thank you.
When I select it, I wish the box shows the first 3 characters only. How can do this?
Thank you.
Following...®
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is it your means?
set combobox1's style property =csOwnerDrawFixed
procedure TForm1.ComboBox1DrawItem(C ontrol: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
ComboBox1.Canvas.FillRect( rect);
if State=[odselected,odfocuse d,odCombob oxEdit] then begin
ComboBox1.Canvas.Textout(r ect.left,R ect.top,Co mboBox1.It ems[Index] );
exit;
end;
if state=[odselected,odfocuse d] then begin
ComboBox1.Canvas.Textout(r ect.left,R ect.top,co py(ComboBo x1.Items[I ndex],0,3) );
end else begin
ComboBox1.Canvas.TextOut(R ect.Left,R ect.top,Co mboBox1.It ems[Index] );
end;
end;
set combobox1's style property =csOwnerDrawFixed
procedure TForm1.ComboBox1DrawItem(C
Rect: TRect; State: TOwnerDrawState);
begin
ComboBox1.Canvas.FillRect(
if State=[odselected,odfocuse
ComboBox1.Canvas.Textout(r
exit;
end;
if state=[odselected,odfocuse
ComboBox1.Canvas.Textout(r
end else begin
ComboBox1.Canvas.TextOut(R
end;
end;
this will do it, if you leave the combobox
procedure TForm1.ComboBox1Exit(Sende
begin
combobox1.Text := copy(combobox1.Items[combo
end;
meikl