Advertisement
idsystems

CPP_RAD_Ejercicio33

May 20th, 2012
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.65 KB | None | 0 0
  1. /* ej33_ListBox
  2. Ejemplo del control ListBox */
  3. #include <radc++.h>
  4.  
  5. Form Form1("List Box ejemplo - RAD C++ Ejemplo");
  6. ListBox list("", AUTO_ID, 10, 15, 100, 200, Form1);//create new list 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("Selecciona Entrada", 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 listbox
  25.         list.add("entrada 1");
  26.         list.add("entrada 2");
  27.         list.add("entrada 3");
  28.         list.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(list) {
  40.             txt_selected.text = list[list.selectedItemIndex];
  41.         }
  42.         ON_COMMAND_BY(btn_add) {
  43.             //add new value of textbox txt_newval ot listbox
  44.             list.add(txt_newval.text);
  45.         }
  46.         ON_COMMAND_BY(btn_remove) {
  47.             //remove selected item in listbox
  48.             list.remove(list.selectedItemIndex);
  49.         }
  50.         ON_COMMAND_BY(btn_select) {
  51.             //remove selected item in listbox
  52.             list.select(1); //1 means item 2, items have ZERO based indeses
  53.         }      
  54.         return 0;      
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement