hi, I had a problem when I tried to display data into a combobox and retrieve the Id for the data selected some times is numeric anothers alphanumeric, but I found a piece of code that helps me displaying my data for columns; but I need write the same code for each comobobox into DrawItem, How Can I write just one time this event and assign it on runtime maybe?

, the code is :
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
ARect: TRect; State: TOwnerDrawState);
var
sValor, sTodo: string;
i, iPos: Integer;
rc: TRect;
AnchoColumna: array[0..3] of Integer;
begin
ComboBox1.Canvas.FillRect( ARect );
sTodo := ComboBox1.Items[Index];
// Establecemos el ancho de las columnas
AnchoColumna[0] := 0;
AnchoColumna[1] := 200; // Ancho de la columna 1
AnchoColumna[2] := 300; // Ancho de la columna 2
AnchoColumna[3] := 0; // Ancho de la columna 3
// Leemos el texto de la primera columna
iPos := Pos( ';', sTodo );
sValor := Copy( sTodo, 1, iPos - 1 );
for i := 0 to 2 do
begin
// Dibujamos la primera columna
rc.Left := ARect.Left + AnchoColumna
+ 2;
rc.Right := ARect.Left + AnchoColumna[i+1] - 2;
rc.Top := ARect.Top;
rc.Bottom := ARect.Bottom;
// Escribimos el texto
Combobox1.Canvas.TextRect( rc, rc.Left, rc.Top, sValor );
// Dibujamos las líneas que separan las columnas
if i < 3 then
begin
Combobox1.Canvas.MoveTo( rc.Right, rc.Top );
Combobox1.Canvas.LineTo( rc.Right, rc.Bottom );
end;
// Leemos el texto de la segunda columna
sTodo := Copy( sTodo, iPos + 1, Length( sTodo ) - iPos );
iPos := Pos( ';', sTodo );
sValor := Copy( sTodo, 1, iPos - 1 );
end;
end;
//Add Items to ComboBox
ComboBox1.Style:= csOwnerDrawVariable;
with Combobox1.Items do
begin
Add( 'DOLLAR;USD1;' );
Add( 'PESO;MX1;' );
Add( 'EURO;EUR;' );
Add( 'YEN;YEN;' );
end;