Problem with add listview items


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: Problem with add listview items

  1. #1
    Join Date
    Apr 2011
    Posts
    20

    Problem with add listview items

    Hi guys,

    I need your help. I am using managed c++/cli to code for my project. I know how to add the listview items by extact the data from the website. Now I just want to know how I can do the autosearch in the textbox to search the actual items in the listview?

    I have tried this:

    Code:
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    using namespace System::Net;
    using namespace System::Text::RegularExpressions;
    using namespace System::IO;
    using namespace System::Text;
    using namespace System::Web;
    using namespace System::Configuration;
    using namespace System::Collections::Generic;
    using namespace System::Runtime::InteropServices;
    
    private:
    	bool isMatch(ListViewItem ^lvi)
    	{
    		return lvi->Text->StartsWith(TextBox1->Text);
    	}
    
    private: System::Void TextBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
    
    			Random ^r = gcnew Random();
    			List<ListViewItem^> ^items = gcnew List<ListViewItem^>();
    			array<ListViewItem^> ^filteredItems = Array::FindAll(items->ToArray(), gcnew System::Predicate<ListViewItem^>(this, &Form2::isMatch));
    			ListView1->Items->Clear();
    			ListView1->Items->AddRange(filteredItems);
    		 }
    
    private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) {
    
    			 MessageBox::Show("timer starts now");
    			 timer1->Enabled = false;
    			 Form2 ^form7 = gcnew Form2();
    
    			 try
    			 {
    				 //Address of URL
    				 String ^URL = "http://www.mysite.com/login.php?user=" + form2->ComboBox1->Text + "&pass=" + form2->TextBox1->Text;
    				 HttpWebRequest ^request = safe_cast<HttpWebRequest^>(WebRequest::Create(URL));
    				 HttpWebResponse ^response = safe_cast<HttpWebResponse^>(request->GetResponse());
    				 StreamReader ^reader = gcnew StreamReader(response->GetResponseStream());
    				 String ^str = reader->ReadToEnd();
    
    				 String ^pattern1 = "(<p id='myid1'>(.*?)</p>)";
    				 MatchCollection ^matches1 = Regex::Matches(str, pattern1);
    
    				Random ^r = gcnew Random();
    				List<ListViewItem^> ^items = gcnew List<ListViewItem^>();
    
    				 for each (Match ^x1 in matches1)
    				 {
    		 array<String^> ^StrArr1 = x1->Value->ToString()->Split();
    		 items->Add(gcnew ListViewItem(gcnew array<String^> {x1->Value->ToString()->Replace("<p id='myid1'>", "")->Replace("</p>", "")}));
    				 }
    				 ListView1->Items->AddRange(items->ToArray());
    			 }
    			 catch (Exception ^ex)
    			 {
    				 MessageBox::Show("the site you request is down!");
    			 }
    		 }


    It doesn't work. None of the listview items have been adding in the listview.

    Do you know what the problem is?



    Any advice would be much appreicate.

    Thanks,
    Mark

  2. #2
    Join Date
    Apr 2011
    Posts
    20
    Does anyone know how to do this?

  3. #3
    Join Date
    Dec 2003
    Posts
    3,366
    I can barely read it, much less fix it, but you might repost this in the .NET programmer area if no one here can help. Sorry but managed code just isnt c++, they changed so much its a new language.

    http://forums.devx.com/forumdisplay.php?f=120

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    I moved it to the .NET section so reposting isn't necessary.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  5. #5
    Join Date
    Apr 2011
    Posts
    20
    Thanks Hack, so do anyone know how to solution this?

  6. #6
    Join Date
    Apr 2011
    Posts
    20
    anyone know how to solution this?

  7. #7
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Does this help?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Replies: 1
    Last Post: 09-16-2006, 08:37 PM
  2. Replies: 0
    Last Post: 11-19-2002, 10:23 PM
  3. Replies: 0
    Last Post: 11-19-2002, 11:34 AM
  4. Deleting ListView items crashes VB6Sp3 ?
    By dotScience in forum VB Classic
    Replies: 4
    Last Post: 06-23-2000, 07:02 PM
  5. Replies: 0
    Last Post: 05-18-2000, 01:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center