C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




performance issue in listbox


Posted Date: 21 Jan 2008      Total Responses: 1

Posted By: prasannakumar       Member Level: Gold     Points: 2


hi,
i am remove the item in listbox using arraylist and for loop. for loop is decrease application performance. any other alternative solution for this?

This is my code

Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
dim oArrlist as new Arraylist
Try
'load the item into arraylist.
For i = 0 To ListBox1.Items.Count - 1
If (ListBox1.Items(i).Selected = True) Then
oArrlis.Add(ListBox1.SelectedItem.Text)
End If
Next
'Remove the item
For j = 0 To oArrlis.Count - 1
If (oArrlis.Count <> 0) Then
ListBox1.Items.Remove(oArrlis(j).ToString())
End If
Next
Catch ex As Exception
ex.Message.ToString()
End Try
End Sub




Responses

Author: Shanmugam    21 Jan 2008Member Level: GoldRating:     Points: 2
Use for each .

For Each item As ListItem In ListBox1.Items
If (item.Selected) Then
oArrlis.Add(item.Text)

End If
Next



Post Reply
You must Sign In to post a response.
Next : to send an value from a child window to parent window
Previous : how to sort fileds in datatable
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

audio conferencing services

Contact Us    Privacy Policy    Terms Of Use