Let's say I have 3 text boxes called item_name,item_price,item_type. And there is a listbox that has the item_name and another list box that has item_price, another one with the item_type. Let;s say we want to click on the item_name. After clicking on the item_name list box's first item. how to get its corresponding item_price and item_type to 3 text boxes separately. I can take them only if 3 listboxes are clicked. I want this to happen after clicking only the item_name listbox.

How do you know which items in the other two list boxes belong to the one you select in item_name? Are the positions in the list boxes the same so that if you select the 5th item in item_name then you will need to get the 5th item in each of the other two list boxes? That will only work if none of the list boxes are sorted.

Is there a reason you need three list boxes instead of just one? If there is only one then you can have an array of structure or class that contains all three items. When you select an item from item_name search the array for an entry with the same item_name and populate the three text boxes with the information in that structure/class. That is a much safer and easier way to do it, and makes the window look clearner because it has only one list box instead of three.

my program


If I click on "cat", which is the item_name, I want to be able to add all item_name,item_type,quantity and price to the , text boxes next to the lables, item_name,item_type,quanitity and price.

By using "lsitbox.selecteditem", I can add only one list box item. We must select all 4 listboxes seperately for that to happen using "slectedItem" method.

my program and an image capture is here.

Attach the first file to your post instead of posting a link to it on some other server.

I would suggest, instead of 3 listboxes, use 1 listview. That way all your data is in one place and very easy to correlate. You can even use it to get the info directly from your database.

Consider the possibilities of a DataGridView.

@ddanbe. I can't make it to auto refresh after every addition. I tried it before

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.