Don't like ads? PRO users don't see any ads ;-)
Guest

CPP_RAD_Ejercicio34

By: idsystems on May 20th, 2012  |  syntax: C++  |  size: 1.67 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /* ej34_ComboBox
  2. Ejemplo de control ComboBox */
  3. #include <radc++.h>
  4.  
  5. Form Form1("Combo Box ejemplo - RAD C++ Ejemplo");
  6. ComboBox combo("", AUTO_ID, 10, 15, 100, 200, Form1);//create new combo box
  7.  
  8. Button btn_add("<   Agregar esto   <", AUTO_ID, 120, 15, 100, 25, Form1);
  9. TextBox txt_newval("Nuevo valor", AUTO_ID, 230, 15, 150, 25, Form1);
  10.  
  11. Label   label("Entrada Seleccionada", AUTO_ID, 120, 45, 260, 15, Form1);
  12. ReadOnlyBox txt_selected("", AUTO_ID, 120, 60, 260, 25, Form1);
  13.  
  14. Button btn_remove("[ X ] Remover seleccion", AUTO_ID, 120,130, 260, 25, Form1);
  15. Button btn_select("Progmaticamente seleccionar item 2", AUTO_ID, 120,160, 260, 25, Form1);
  16.  
  17. FormProcedure procedure1 (FormProcArgs); //prototype of form procedure
  18.  
  19. rad_main()
  20.  
  21.                 //attach form procedure
  22.                 Form1.procedure = procedure1;
  23.  
  24.                 //add some enteries to combobox
  25.                 combo.add("entrada 1");
  26.                 combo.add("entrada 2");
  27.                 combo.add("entrada 3");
  28.                 combo.select(0); //select first entry
  29.  
  30. rad_end()
  31.  
  32. FormProcedure procedure1 (FormProcArgs) { //implementation of form procedure
  33.  
  34.                 ON_CLOSE() {
  35.                         //exit application
  36.                         Application.close();
  37.                 }
  38.                 //when an item is selected, put its text in textbox txt_selected
  39.                 ON_ITEMSELECT(combo) {
  40.                         txt_selected.text = combo[combo.selectedItemIndex];
  41.                 }
  42.                 ON_COMMAND_BY(btn_add) {
  43.                         //add new value of textbox txt_newval ot combobox
  44.                         combo.add(txt_newval.text);
  45.                 }
  46.                 ON_COMMAND_BY(btn_remove) {
  47.                         //remove selected item in combobox
  48.                         combo.remove(combo.selectedItemIndex);
  49.                 }
  50.                 ON_COMMAND_BY(btn_select) {
  51.                         //remove selected item in combobox
  52.                         combo.select(1); //1 means item 2, items have ZERO based indeses
  53.                 }      
  54.                 return 0;      
  55. }