ComboBoxEx-eintrag ein Bitmap anfügen



  • Hallo zusammen,

    Ich habe schon gesucht, aber keine Lösung für mein Problem gefunden.

    Ich erstelle zur Laufzeit ein Bitmap, weise es einer Imagelist zu.
    Die Imagelist ist einer ComboBoxEx zugeordnet.

    Ich füge einen neuen Listeneintrag an die Combobox und bekomme das Bitmap einfach nicht zum Eintrag.

    Wer kann mir mit einem kleinen Codeschnipsel helfen.

    Hier mein Code:

    void __fastcall TForm1::zeichneNeuesBitmap()
    {
      /*                     Farbe von Label4 holen                     */
      Graphics::TColor *Coll = new Graphics::TColor();
      *Coll = TColor(this->Label4->Color);
    
      /*                     Bitmap erstellen                           */
      Graphics::TBitmap *Bitsmap = new Graphics::TBitmap();
      Bitsmap->Width  = 16;
      Bitsmap->Height = 16;
    
      /*                     Quadrat in das Bitmap zeichnen             */
      Bitsmap->Canvas->Brush->Color = clBtnFace;
      Bitsmap->Canvas->Rectangle(-1,-1,17,17);
    
      /*                     Kreis in das Bitmap zeichnen               */
      Bitsmap->Canvas->Brush->Color = *Coll;
      Bitsmap->Canvas->Ellipse(0,0,16,16);
    
      /*                     Bitmap der ImageList1 zuordnen             */
      /*                     ImageList1 ist der Combobox zugewiesen     */
      this->ImageList1->AddMasked(Bitsmap, clBlack);
    
      /*                     String für die Combobox zusammenstellen    */
      AnsiString tx = " => Hexadezimal: ( #" + txtHexa->Text + " ) => " +
                      "RGB: ( " + txtR->Text + ", " + txtG->Text + ", " + txtB->Text + " ) => " +
                      "System: ( " + txtLong->Text + " )";
    
      /*                     String der Combobox übergeben              */
      this->ComboBoxEx1->AddItem(tx, (TObject *)Bitsmap);
    
      /*                     Den letzten eintrag der Combobox auswählen */
      ComboBoxEx1->ItemIndex = ComboBoxEx1->Items->Count - 1;
    
      /*                     PROBLEM !!!                                */
      /* Hier ist mein Problem.                                         */
      /* Ich bekomme das Bitmap nicht in die Combobox                   */
      //this->ComboBoxEx1->ItemsEx->Items //usw.... komme nicht weiter
    
      /*                     Bitmap freigeben                           */
      delete Bitsmap;
    }
    


  • Habs selber gefunden,

    Die zu ergänzende Zeile muß so aussehen

    this->ComboBoxEx1->ItemsEx->Items[0]->ImageIndex = ComboBoxEx1->Items->Count - 1;
    

Anmelden zum Antworten