Click here to Skip to main content
15,941,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 3 comboBox and 3 ListBox
1 comboBox is item code
2 comboBox is credit
3 comboBox is debit

and it is inserting values in its 3 individual listboxs.

i want when i insert value in to list boxes from comboboxes it must only insert new itemcode with credit and debit.
if item code exsist in the listbox alredy then it must update that itemcode's credit and debit.
Posted

1 solution

Something like this ...
int index = listItemCode.Items.IndexOf(cbItemCode.Text);
if( index >= 0 )
{
	//Amend the corresponding entries in the other list boxes
	listCredit.Items[index] = cbCredit.Text;
	listDebit.Items[index] = cbDebit.Text;
}
else
{
	//Add this as a new item
	listItemCode.Items.Add(cbItemCode.Text)
	listCredit.Items.Add(cbCredit.Text);
	listDebit.Items.Add(cbDebit.Text);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900