更新列表框,如果它有来自组合框的值,则插入到组合框中 [英] update listbox if it have value from combobox else insert in to combobox

查看:82
本文介绍了更新列表框,如果它有来自组合框的值,则插入到组合框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个comboBox和3个ListBox

1个comboBox是项目代码

2 comboBox是信用

3 comboBox是debit



并且它在3个单独的列表框中插入值。



i当我将值插入到列表框中时组合框它必须只插入带有信用卡和借记卡的新商品代码。

如果项目代码在列表框中存在,则必须更新该商品代码的信用卡和借记卡。

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.

推荐答案

像这样......

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);
}


这篇关于更新列表框,如果它有来自组合框的值,则插入到组合框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆