Unit1.pas 946 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. unit Unit1;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, StdCtrls;
  6. type
  7. TForm1 = class(TForm)
  8. btn1: TButton;
  9. cbb1: TComboBox;
  10. procedure btn1Click(Sender: TObject);
  11. private
  12. { Private declarations }
  13. public
  14. { Public declarations }
  15. end;
  16. var
  17. Form1: TForm1;
  18. implementation
  19. {$R *.dfm}
  20. { Realiza la acción del botón. }
  21. procedure TForm1.btn1Click(Sender: TObject);
  22. begin
  23. if cbb1.ItemIndex = 0 then
  24. begin
  25. Color := ClRed;
  26. end
  27. else if cbb1.ItemIndex = 1 then
  28. begin
  29. Color := ClGreen;
  30. end
  31. else if cbb1.ItemIndex = 2 then
  32. begin
  33. Color := ClBlue;
  34. end;
  35. { Alternativa analizando el contenido del radio button. }
  36. {
  37. if cbb1.Text = 'Rojo' then
  38. begin
  39. Color := ClRed;
  40. end
  41. else if cbb1.Text = 'Verde' then
  42. begin
  43. Color := ClGreen;
  44. end
  45. else if cbb1.Text = 'Azul' then
  46. begin
  47. Color := ClBlue;
  48. end;
  49. }
  50. end;
  51. end.