title: Creating a TCustomComboBox descendant in Delphi
body: <p>I am trying to create a custom control based on the TCustomComboBox in Delphi 2007, But I am stuck on the first hurdle.</p>
  
  <p>I am trying to override the way the drop down is displayed, primarally the text that is displayed, looking at the source for TCustomComboBox in stdctrls.pas it looks like i just need to  override DrawItem but it is not working, as the code in my overridden method is never executed.</p>
  
  <p>I have looked a several open source components source code to see how they do it, but I am still at a loss.</p>
  
  <p>Here is what I have so far (not much admittedly)</p>
  
  <pre><code>type
    TKeyValueComboBox = class(TCustomComboBox)
    private
      { Private declarations }
      //FColumns:Integer;
    protected
      { Protected declarations }
      procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);override; 
    public
      { Public declarations }
      constructor Create(AOwner: TComponent); override;
      destructor Destroy; override;
    published
  end;
  </code></pre>
  
  <p>And </p>
  
  <pre><code>procedure TKeyValueComboBox.DrawItem(Index: Integer; Rect: TRect;
    State: TOwnerDrawState);
  begin
    TControlCanvas(Canvas).UpdateTextFlags;
    if Assigned(OnDrawItem) then OnDrawItem(Self, Index, Rect, State)
    else
    begin
      Canvas.FillRect(Rect);
      Canvas.TextOut(Rect.Left + 2, Rect.Top, Items[Index]+'-HELLO');
    end;
  end;
  </code></pre>
  
  <p>Does anyone know what method I need to use to get my overridden version of fire? or what I am doing wrong?</p>
  
  <p>Any help would be appreciated.</p>