Advertisement
idsystems

CPP_RAD_Ejercicio37

May 20th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. /* ej37_ListView
  2. Ejemplo de control ListView */
  3. #include <radc++.h>
  4.  
  5. Form Form1("List View ejemplo - RAD C++ Ejemplo");
  6. Label          label("Item de texto Seleccionado:", -1, 50, 10, 300, 25,  Form1);
  7. ReadOnlyBox    text1("",                    -1, 50, 40, 300, 25,  Form1);
  8. ListView       listv("",               AUTO_ID, 50, 75, 300, 160, Form1);//create new listview
  9.  
  10. FormProcedure procedure1 (FormProcArgs) {
  11.         ON_CLOSE() Application.close();
  12.         ON_OBJECTSELECT(listv) { //item has been selected in listview
  13.             int selection = listv.selectedItemIndex;
  14.             if(selection == -1) //nothing selected, it was just some other event
  15.                 text1.text = "Actualmente sin seleccion!";
  16.             else
  17.                 text1.text = listv[listv.selectedItemIndex];
  18.         }
  19.         return 0;      
  20. }
  21.  
  22. //create new iconlist, RCP_LARGE becuase listview accepts large icons
  23. IconList icl(RCP_LARGE);
  24. //create some icon objects
  25. Icon icon1(IDI_HAND), icon2(IDI_ASTERISK),icon3(IDI_APPLICATION), icon4(IDI_EXCLAMATION) ;
  26.  
  27. rad_main()
  28.  
  29.         //attach form procedure
  30.         Form1.procedure = procedure1;
  31.  
  32.         //add icons to icon list
  33.         icl.add(icon1);
  34.         icl.add(icon2);
  35.         icl.add(icon3);
  36.         icl.add(icon4);
  37.        
  38.         //now attach iconlist to listview
  39.         listv.setIconList(icl);
  40.  
  41.         //add some enteries to listview
  42.         //note: 2nd argument is reserved and msut be empty string ""
  43.         listv.add("entrada 1","",1); //3rd argument is ZERO basded index of icon in list
  44.         listv.add("entrada 2","",2);
  45.         listv.add("entrada 3","",3);
  46.         listv.add("a. con icono default"); //did not pass last 2 arguments  so first icon is selected
  47.         listv.add("b. con icono default"); //did not pass last 2 arguments  so first icon is selected
  48.  
  49. rad_end()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement