-
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
-
Does anyone know how to do this?
-
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
-
I moved it to the .NET section so reposting isn't necessary.
-
Thanks Hack, so do anyone know how to solution this?
-
anyone know how to solution this?
-
Similar Threads
-
By vb_programmer in forum VB Classic
Replies: 1
Last Post: 09-16-2006, 07:37 PM
-
Replies: 0
Last Post: 11-19-2002, 09:23 PM
-
Replies: 0
Last Post: 11-19-2002, 10:34 AM
-
By dotScience in forum VB Classic
Replies: 4
Last Post: 06-23-2000, 06:02 PM
-
By Venkatesh in forum Java
Replies: 0
Last Post: 05-18-2000, 12: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
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|