LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

displaying data in single row and different colums in listbox

Solved!
Go to solution

Hi I want to disply data in different columns and same row in listbox using InsertListItem() but it displays the data in different rows.....I am using escape sequence for creating columns....Also I want to display an integer which I have converted to string using sprintf() on the listbox with a word, eg 10Kg where 10 is stored in some variable and I have to add Kg, How to do it in a single InsertItemList() call...Thank you

 

If you are young work to Learn, not to earn.
0 Kudos
Message 1 of 7
(3,173 Views)

A single InsertListItem creates a single row in the listbox. All formatting and escape codes for the whole line to be inserted in the listbox must go in a single label to be passed to the function.

Could you post here your code so that we can revise it?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 7
(3,162 Views)

Thank you so much.....here the part of my code

InsertListItem (panel,PANEL_LISTBOX , 0, "#\033p30lItem\033p100lPackage\033p170lRate\033p220lPrice", 0);  //this fills the first row
InsertListItem (panel,PANEL_LISTBOX , 1, j, 1);  /*in the first column
                    I have to display serail no which changes each time*/
InsertListItem (panel,PANEL_LISTBOX , 1,"\033p30lFlour", 1); 
//then I have to display a different item in each column in which some are variables like rate/price etc and some

 

If you are young work to Learn, not to earn.
0 Kudos
Message 3 of 7
(3,158 Views)
Solution
Accepted by topic author Dreamer14388

I see: you need to create the entire row before adding it to the listbox:

 

sprintf (string, "&d\033p30l%s\033p100l%s\033p170l%d\033p220l%.2f", itemNo, itemName, itemPack, 123, 15.98);
InsertListItem (panel, PANEL_LISTBOX , 0, string, 0);

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 7
(3,136 Views)

Another option is to use a tree control, which can be configured to look like a list control. The tree control supports proper columns. Check out http://forums.ni.com/ni/board/message?board.id=180&message.id=13541#M13541 for more info.

0 Kudos
Message 5 of 7
(3,126 Views)
char * itemName[]={"item1","item2","item3","item4","item5","item6"};
char * itemPack[]={"10Kg","20Kg","40Kg","80Kg"};

void display_list(int j,int item_index,int pack_index,int rate, int quantity,int price)
{
	sprintf(string,"%d\033p30l%s\033p100l%s\033p170%d\033p220l%d\033p270l%d",j,itemName[item_index],
		itemPack[pack_index],rate,quantity,price);
	InsertListItem (panelHandle,PANEL_LISTBOX , -1, string,0);
}  //I am calling this function to display the data 

//The item and pack are selected and then I set their indexes //accordingly and then pass them to the above function to display
//the rate and quantity is also passed to the function
price = rate * quantity;
display_list(i,item_index,pack_index,rate,quantity,price);

 I am doing this but the problem is that it only displays the price in the last column of the list box and doesn't display the other things.......Please tell me what I am doing wrong in the above code...

If you are young work to Learn, not to earn.
0 Kudos
Message 6 of 7
(3,104 Views)

I can only see a missing alignment code in this line: correct it and test again.

 

sprintf (string, "%d\033p30l%s\033p100l%s\033p170x%d\033p220l%d\033p270l%d", j, itemName[item_index],
        itemPack[pack_index], rate, quantity, price);




Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 7 of 7
(3,097 Views)