Get values from ListBox
-
hi all, :) I have ListBox where are 10 items. i set ListBox.DisplayMember = "FirstName"; ListBox.ValueMember = "EmployeeID"; then ListBox shows the Employee's FirstName.My problem is that how do i get the all EmployeeID from ListBox? :(
-
hi all, :) I have ListBox where are 10 items. i set ListBox.DisplayMember = "FirstName"; ListBox.ValueMember = "EmployeeID"; then ListBox shows the Employee's FirstName.My problem is that how do i get the all EmployeeID from ListBox? :(
ListControl.SelectedValue Property [^] will return the value for selected item.
The need to optimize rises from a bad design. My articles[^]
-
hi all, :) I have ListBox where are 10 items. i set ListBox.DisplayMember = "FirstName"; ListBox.ValueMember = "EmployeeID"; then ListBox shows the Employee's FirstName.My problem is that how do i get the all EmployeeID from ListBox? :(
Hi ... I think it's good for you:
List val = new List(); for (int i = 0; i < listBox1.Items.Count; i++) { lst.SelectedIndex = i; val.Add((Int32)lst.SelectedValue); }
In val you have All EmployeeIDs ... But this code is not logical code X| ...
if(Human.live)
{
Human.peaceful = false;
while(true)
{
Human.love(Human girl, Human Boy);
}
} -
Hi ... I think it's good for you:
List val = new List(); for (int i = 0; i < listBox1.Items.Count; i++) { lst.SelectedIndex = i; val.Add((Int32)lst.SelectedValue); }
In val you have All EmployeeIDs ... But this code is not logical code X| ...
if(Human.live)
{
Human.peaceful = false;
while(true)
{
Human.love(Human girl, Human Boy);
}
}i found ArrayList objList = new ArrayList(); foreach (DataRowView obj in listBox1.Items) { objList.Add(obj[0]); } :-D :-D :-D
-
i found ArrayList objList = new ArrayList(); foreach (DataRowView obj in listBox1.Items) { objList.Add(obj[0]); } :-D :-D :-D
You should rather use a generic list (The ArrayList class is practically deprecated):
List<object> objList = new List<object>(listBox1.Items);
or just get a reference to the Items collection:ListBox.ObjectCollection objList = listBox1.Items;
Despite everything, the person most likely to be fooling you next is yourself.