• Viernes 3 de Mayo de 2024, 03:48

Autor Tema:  Lista Con Combox  (Leído 1421 veces)

rp_group

  • Nuevo Miembro
  • *
  • Mensajes: 1
    • Ver Perfil
Lista Con Combox
« en: Jueves 24 de Febrero de 2005, 21:49 »
0
Hola:
Necesito que en mi aplicacion, en tiempo de ejecución, se cree una lista que contenga varios combobox.
Pense en insertar un combobox en una celda de un grid, o en un item de un listview, pero no lo he logrado.

¿Alguien puede, por favor, darme sugerencias acerca de cómo puedo lograrlo? ¿Qué componentes puedo usar?

Gracias por la atención

saludos, rp_group
 :unsure:

_Viktor

  • Miembro MUY activo
  • ***
  • Mensajes: 271
    • Ver Perfil
    • http://AyudaCBuilder.foros.st
Re: Lista Con Combox
« Respuesta #1 en: Viernes 25 de Febrero de 2005, 01:49 »
0
Para un ComboBox sobre un StringGrid puedes hacer lo siguiente

Agrega un StringGrid y un ComboBox... a este ultimo agregale los siguientes items...

"soltero"
"casado"
"separado"
"viudo"

He implemente el siguiente codigo:

Código: Text
  1.  
  2. //---------------------------------------------------------------------------
  3. #include <vcl.h>
  4. #pragma hdrstop
  5.  
  6. #include "Unit1.h"
  7. //---------------------------------------------------------------------------
  8. #pragma package(smart_init)
  9. #pragma resource "*.dfm"
  10. TForm1 *Form1;
  11. //---------------------------------------------------------------------------
  12. __fastcall TForm1::TForm1(TComponent* Owner)
  13.     : TForm(Owner)
  14. {
  15. }
  16. //---------------------------------------------------------------------------
  17. void __fastcall TForm1::FormCreate(TObject *Sender)
  18. {
  19.     StringGrid1->Cells[0][0] = "Nombre";
  20.     StringGrid1->Cells[1][0] = "Apellido";
  21.     StringGrid1->Cells[2][0] = "Sexor";
  22.     StringGrid1->Cells[3][0] =  "Estado civil";
  23.     StringGrid1->Cells[4][0] = "Email";
  24.     StringGrid1->Cells[5][0] = "Fono P.";
  25.     StringGrid1->Cells[6][0] = "Celular";
  26.     StringGrid1->Cells[7][0] = "Otro";    
  27. }
  28. //---------------------------------------------------------------------------
  29. void __fastcall TForm1::StringGrid1Click(TObject *Sender)
  30. {
  31.     if( StringGrid1->Col == 3 )
  32.     {
  33.         TRect Recto     = StringGrid1->CellRect(StringGrid1->Col, StringGrid1->Row);
  34.         ComboBox1->Top  = StringGrid1->Top;
  35.         ComboBox1->Left = StringGrid1->Left;
  36.         ComboBox1->Top  = ComboBox1->Top + Recto.Top + StringGrid1->GridLineWidth;
  37.         ComboBox1->Left = ComboBox1->Left + Recto.Left + StringGrid1->GridLineWidth + 1;
  38.         ComboBox1->Height = (Recto.Bottom - Recto.Top) + 1;
  39.         ComboBox1->Width  = Recto.Right - Recto.Left;
  40.         ComboBox1->Visible = True;
  41.     }
  42.     else
  43.         ComboBox1->Visible = False;
  44. }
  45. //---------------------------------------------------------------------------
  46. void __fastcall TForm1::ComboBox1Change(TObject *Sender)
  47. {
  48.     StringGrid1->Cells[StringGrid1->Col][StringGrid1->Row] =
  49.      ComboBox1->Items->Strings[ComboBox1->ItemIndex];
  50. }
  51. //---------------------------------------------------------------------------
  52.  
  53.  
  54.  


Saludos... Espor te sirva...
_Viktor _Yañez_
"Ser inteligente no es ser mas, solo equivocarse menos y no usar visual basic"

http]