LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how can i programmatically fill out an activex listview control

Hello,  i am working with LabWindows/CVI 8.5,
i need some help with a listview control. I have included a microsoft windows common controls 6 to my project.
 
I have dropped a listview control on my form and i want to add dynamic some listitems or lines to the listview.
So, i am trying to use MSComctlLib_IListItemsAdd(...) function and  MSComctlLib_IListViewSetListItems(...) functions, but nothing happens. With a errinfo i have found out, there is a error occurs with parameter passing to this functions, but i can not find out why. The VARIANT data type is a default type of the parameters.
 
 I need some little example, how can i fill the listview control.
Is there some special algorithm to use a such control or not? How can i create dynamic columns in a control?
 
Thanks
0 Kudos
Message 1 of 2
(3,108 Views)

Hi Boris,

Here is a quick snippet that programmatically adds a column and then adds a list item.

// Get handle to activex control
GetObjHandleFromActiveXCtrl (panelHandle, PANEL_LISTVIEW, &listViewHandle);
 
// Set view of listview control to report
MSComctlLib_IListViewSetView (listViewHandle, NULL, MSComctlLibConst_lvwReport);

// Add a column header
status = MSComctlLib_IListViewGetColumnHeaders (listViewHandle, NULL, &columnHeaders);
CA_VariantSetCString (&columnHeaderText, "Column 1");
CA_VariantSetInt(&index, 1);
status = MSComctlLib_IColumnHeadersAdd (columnHeaders, NULL, index, CA_DEFAULT_VAL, columnHeaderText, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, &columnHeader);
   
// Add an item
MSComctlLib_IListViewGetListItems (listViewHandle, NULL, &listItems);
CA_VariantSetCString (&myText, "Hello there");
status = MSComctlLib_IListItemsAdd (listItems, NULL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, myText, CA_DEFAULT_VAL, CA_DEFAULT_VAL, &listItem); 

Hope this helps!

Best Regards,



Message Edited by Jonathan N on 02-08-2008 08:57 AM
Jonathan N.
National Instruments
0 Kudos
Message 2 of 2
(3,102 Views)