• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1701
  • Last Modified:

Combobox, input when style = csOwnerDrawFixed


I want to draw different items in a
combobox with different colors.

My problem is that when style = csOwnerDrawFixed, it is no longer possible to enter text into the combobox. The delphi5 help-file says that :
" csOwnerDrawFixed :Creates an owner-draw drop-down list with an edit box for manually entered text."
   
What am I doing wrong ?
0
christha
Asked:
christha
1 Solution
 
AttarSoftwareCommented:
This is a bug...  If the combobox is owner draw, then you cannot enter text in the top bit...  Eventhe Delphi property editor doesn't do this (see the colour dropdown combo, on all controls)...

Isn't there a drop down event?

Can you set the combobox to csOwnerDraw fixed when this is fired, and back again when it is released?

Otherwise, I know we have an application we wrote here which mimics the property Editor in Delphi by using a paintBox in a scrollbox.  When you select a property, you get a tEdit with a button after it, and when you click on the button, you get an ownerdraw listbox popping up at that position...

Anyway, thats the way we do it...

Hope this helps...

Tim.

PS:  You can probably pick up a component to do what you want from torrys website (http://www.torry.ru I think)

0
 
men xinCEOCommented:
If you wont use any other components...

use a edit component is very easy.

set edit.borderstyle=bsnone
put it on the combobox
add some events:

...
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
  Edit1.Text:=ComboBox1.Text;
end;
...

and you can add some codes in the combobox.onenter & onexit event to control the edit 's enabled or visibled.

menxin

0
 
christhaAuthor Commented:

I tried changing the style to
csOwnerdraw and back, but the result was sort of unpredictable.

The  "fake" combobox ( editbox with
a listbox attached) works fine.
Great idea!

Thanks  :-)  

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now