大家晚上好!我正在寻求帮助,我有一个问题..当我从列表框中删除数据时,如何在组合框中再次传递数据? 首先
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if(comboBox1.Text == "withTax")
{
listBox1.Items.Add(comboBox1.Text);
withtax.Text = "Yes";
comboBox1.Items.Remove(comboBox1.Text);
}
else if (comboBox1.Text == "SSS")
{
listBox1.Items.Add(comboBox1.Text);
SSS.Text = "Yes";
comboBox1.Items.Remove(comboBox1.Text);
}
else if (comboBox1.Text == "PhilHealth")
{
listBox1.Items.Add(comboBox1.Text);
PhilHealth.Text = "Yes";
comboBox1.Items.Remove(comboBox1.Text);
}
else if (comboBox1.Text == "Pag-Ibig")
{
listBox1.Items.Add(comboBox1.Text);
Pagibig.Text = "Yes";
comboBox1.Items.Remove(comboBox1.Text);
}
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = listBox1.SelectedItems.Count -1; i>=0; i--)
{
listBox1.Items.Remove(listBox1.SelectedItems[i]);
comboBox1.Items.Add(listBox1.Items.ToString());
}
}
答案 0 :(得分:0)
切换这两行
constructor(props) {
super(props);
this._didFocusSubscription = props.navigation.addListener('didFocus', payload =>
BackHandler.addEventListener('hardwareBackPress', this.onBackButtonPressAndroid)
);
}
componentDidMount() {
this._willBlurSubscription = this.props.navigation.addListener('willBlur', payload =>
BackHandler.removeEventListener('hardwareBackPress', this.onBackButtonPressAndroid)
);
}
onBackButtonPressAndroid = () => {
BackHandler.exitApp();
return true;
}
像这样
listBox1.Items.Remove(listBox1.SelectedItems[i]);
comboBox1.Items.Add(listBox1.Items.ToString());
在第一行中,您已将其从列表框项中删除,然后您将无法使用它,则应以这种方式进行切换。
并更改此
comboBox1.Items.Add(listBox1.Items.ToString());
listBox1.Items.Remove(listBox1.SelectedItems[i]);
对此
comboBox1.Items.Add(listBox1.Items.ToString());