Advertisement
idsystems

CPP_RAD_Ejercicio35

May 20th, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.84 KB | None | 0 0
  1. /* ej35_MultiColumnListBox
  2. Ejemplo para mostrar el control ListBox con mas de una columna */
  3. #include <radc++.h>
  4.  
  5. Form Form1("Multi-Columna List Box ejemplo - RAD C++ Ejemplo");
  6. MCListBox list("", AUTO_ID, 10, 15, 370, 100, Form1);//create new mc list box
  7.  
  8. Button btn_add("^   Agregrar esto   <", AUTO_ID, 120, 115, 100, 25, Form1);
  9. TextBox txt_newval("nuevo", AUTO_ID, 230, 115, 150, 25, Form1);
  10.  
  11. Label   label("Entrada Seleccionada", -1, 120, 145, 260, 15, Form1);
  12. ReadOnlyBox txt_selected("", AUTO_ID, 120, 160, 260, 25, Form1);
  13.  
  14. Button btn_remove("[ X ] Remover item seleccionado", AUTO_ID, 120,200, 260, 25, Form1);
  15. Button btn_select("Progmaticamente seleccionar item 2", AUTO_ID, 120,230, 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.         for(int i=1; i<=40; i++)
  26.             list.add("item "+str(i));
  27.                
  28.         list.select(0); //select first entry
  29.         list.setColumnWidth(50);
  30.  
  31. rad_end()
  32.  
  33. FormProcedure procedure1 (FormProcArgs) { //implementation of form procedure
  34.  
  35.         ON_CLOSE() {
  36.             //exit application
  37.             Application.close();
  38.         }
  39.         //when an item is selected, put its text in textbox txt_selected
  40.         ON_ITEMSELECT(list) {
  41.             txt_selected.text = list[list.selectedItemIndex];
  42.         }
  43.         ON_COMMAND_BY(btn_add) {
  44.             //add new value of textbox txt_newval ot listbox
  45.             list.add(txt_newval.text);
  46.         }
  47.         ON_COMMAND_BY(btn_remove) {
  48.             //remove selected item in listbox
  49.             int selection=list.selectedItemIndex;
  50.             if(selection==-1)
  51.                 Form1.warnBox("No item seleccionado!");
  52.             list.remove(selection);
  53.         }
  54.         ON_COMMAND_BY(btn_select) {
  55.             //remove selected item in listbox
  56.             list.select(1); //1 means item 2, items have ZERO based indeses
  57.         }      
  58.         return 0;      
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement