如何在选择特定组合框项后从数据库表中填充包含多列的列表框? [英] how to populate a listbox with multiple columns from a databasetable after the selection of a particular combo box item?
本文介绍了如何在选择特定组合框项后从数据库表中填充包含多列的列表框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经选中了所有按钮,如果我点击选择所有按钮,我在支票列表框中有一些名称,那么选中列表框中的所有名称都必须选择............所以
首先我必须选择所有项目后,这些项目应该移动到列表框。
谢谢你
i have select all button and i have some names in checked list box if i click select all button then all names in checked list box have to select............so
first i have to select all items after that those items should be move to listbox.
thank u
推荐答案
尝试如下
try like below
List<string> lstString = new List<string>();
foreach (ListItem li1 in checkedListBoxId.CheckedItems)
{
if (li1.Selected == true)
{
lstString.Add(li1.Text);
}
}
secondListBoxId.DataSource = lstString.Add;
希望这有助于
Hope this helps
假设您要将Listbox1的选定项目移动到Listbox2。
移动功能:
assuming, you want to move selected items of Listbox1 to Listbox2.
Function for moving:
private void MoveListBoxItems(ListBox source, ListBox destination)
{
ListBox.SelectedObjectCollection sourceItems = source.SelectedItems;
foreach (var item in sourceItems)
{
destination.Items.Add(item);
}
while (source.SelectedItems.Count > 0)
{
source.Items.Remove(source.SelectedItems[0]);
}
}
按钮点击呼叫移动功能
Button Click for call moving function
private void first2second_Click(object sender, EventArgs e)
{
MoveListBoxItems(FirstListbox, LastListbox);
}
foreach (ListItem li1 in checkedListBoxId.CheckedItems)
{
(li1.Selected = true)
}
我认为你想要的是什么?
I think is what you want?
这篇关于如何在选择特定组合框项后从数据库表中填充包含多列的列表框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文