Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Initially I was going to say you could use the Contains method of the Items collection however upon a quick test that didn't seem to work. One way of doing it would be something like this...

		private void cmdSearch_Click(object sender, System.EventArgs e)
	{
		if(lvwA.SelectedItems.Count!=0)
		{
			string searchText = lvwA.SelectedItems[0].Text;
			bool found = FindItem(searchText);
		}
	}

	private bool FindItem(string searchText)
	{
		for(int i = 0; i < lvwB.Items.Count; i++)
		{
			if(lvwB.Items[i].Text == searchText)
			{
				return true;
			}
		}
		
		return false;
	}

Anybody looking for a graduate programmer (Midlands, England)?
Posted

Sorry. I should have been more specific. I'm using VB in VS2005.

 

Initially I was going to say you could use the Contains method of the Items collection however upon a quick test that didn't seem to work. One way of doing it would be something like this...

		private void cmdSearch_Click(object sender, System.EventArgs e)
	{
		if(lvwA.SelectedItems.Count!=0)
		{
			string searchText = lvwA.SelectedItems[0].Text;
			bool found = FindItem(searchText);
		}
	}

	private bool FindItem(string searchText)
	{
		for(int i = 0; i < lvwB.Items.Count; i++)
		{
			if(lvwB.Items[i].Text == searchText)
			{
				return true;
			}
		}
		
		return false;
	}

Posted
Private Function FindItems(ByVal searchText As String) As Boolean
       For i As Single = 0 To i < lvwB.Items.Count
           If (lvwB.Items(i).Text = searchText) Then
               Return True
           End If
       Next
       Return False
   End Function

   Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       If (lvwA.SelectedItems.Count <> 0) Then
           Dim searchText As String = lvwA.SelectedItems(0).Text
           Dim found As Boolean = FindItems(searchText)
       End If
   End Sub

Anybody looking for a graduate programmer (Midlands, England)?
Posted

Wow. Excellent. Thank you so much. Works great. Now I'll have to break it down to learn from what you did. Thanks again!

 

Private Function FindItems(ByVal searchText As String) As Boolean
       For i As Single = 0 To i < lvwB.Items.Count
           If (lvwB.Items(i).Text = searchText) Then
               Return True
           End If
       Next
       Return False
   End Function

   Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       If (lvwA.SelectedItems.Count <> 0) Then
           Dim searchText As String = lvwA.SelectedItems(0).Text
           Dim found As Boolean = FindItems(searchText)
       End If
   End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...