Hola Snaked.
Te soy sincero, no sé si termino de entender el planteo de tu problema. Pero por lo que creo haber interpretado, podrías prescindir del arreglo y almacenar tu estructura en el combo eliminándo el ítem y datos directamente desde él.
Ejemplo:
Código PHP:
//...
#include <ctime>
const OBJECTS_TYPE = 4; // Planet, Station, Route, Asteroids
struct stMapp {
String Nombre_Sector;
int objetos;
int tipo_objeto;
//...
} *mapp;
// Cargar struct de "demo" en el ComboBox
void __fastcall TForm1::FormCreate(TObject *Sender)
{
String objType[4] = { "Planet", "Station", "Route", "Asteroids" };
srand( time(NULL) );
ComboBox1->Items->Clear();
for ( int i = 0; i < 30; i++ ) {
mapp = new stMapp;
mapp->Nombre_Sector = (String)"Sector " + rand()%30;
mapp->objetos = rand() % 15;
mapp->tipo_objeto = rand() % OBJECTS_TYPE ;
String s1 = mapp->Nombre_Sector + String( ": " );
ComboBox1->AddItem(s1 + objType[rand()%4], (TObject*)mapp );
}
ComboBox1->Sorted = true;
ComboBox1->ItemIndex = 0;
}
// Borrar item seleccionado
void __fastcall TForm1::btnDeleteClick(TObject *Sender)
{
if (ComboBox1->ItemIndex != -1 )
ComboBox1->Items->Delete(ComboBox1->ItemIndex);
}
// Mostrar datos struct de item seleccionado
void __fastcall TForm1::btnShowClick(TObject *Sender)
{
stMapp* mp = (stMapp*) ComboBox1->Items->Objects[ComboBox1->ItemIndex];
Memo1->Lines->Add(mp->Nombre_Sector);
Memo1->Lines->Add(mp->objetos);
Memo1->Lines->Add(mp->tipo_objeto);
}
//...
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
delete mapp;
}
Saludos
