Thread: how to tick each checkbox in the listview?

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    40

    how to tick each checkbox in the listview?

    Hi guys,

    I need your urgently help. I have extract each strings from mystrings to input them in the listview. Now I want to know how i can tick the checkboxes for each array in the listview when i'm checking for each "enabled" strings in the php source on each line?

    Here's the code:

    Code:
    System::Void Form1::timer1_Tick(System::Object^  sender, System::EventArgs^  e)
    {
        timer1->Enabled = false;
        timer1::Stop();
    
        try
        {
            String ^URL1 = "http://www.mysite.com/myscript.php?user=test&pass=test";
            HttpWebRequest ^request1 = safe_cast<HttpWebRequest^>(WebRequest::Create(URL1));
            HttpWebResponse ^response1 = safe_cast<HttpWebResponse^>(request1->GetResponse());
            StreamReader ^reader1 = gcnew StreamReader(response1->GetResponseStream());
            String ^str1 = reader1->ReadToEnd();
            String ^pattern1 = "(<p id='mystrings1'>(.*?)</p>(.*?)<span id=\"mystrings2\">Enabled</td>)";
            MatchCollection ^matches1 = Regex::Matches(str1, pattern1);
    
            for each (Match ^x1 in matches1)
            {
                array<String^> ^StrArr1 = x1->Value->ToString()->Split();
                Listview1::Items->Add(x1->ToString());
            }
        }
        catch (Exception ^ex)
        {
        }
    }

    If you do know how to do this, I will be very grateful.

    Thanks,
    Mark

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    It's not C++, but something MS specific - post moved.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    No idea with the langauge specifics, but often with library list type objects there is a value member or equivalent which you can set to 0 or 1, ie checked or not. There may be a member function to select / unselect all children of the list object. And you would expect a whole host of other access methods also. The best, easiest and most accurate thing is probably to check documentation for ListView

    Unless you have written your own implementation, i think the class above is what you are using?
    Last edited by rogster001; 04-07-2012 at 04:24 AM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  4. #4
    Registered User
    Join Date
    Apr 2011
    Posts
    40
    thanks for the help rogster001. Can you please help me how to tick the checkboxes for each listviewitem in the listview when I find each strings from the php source called "enabled" while the strings are on the same line as the strings, e.g the "enabled" strings is on the same line as the "my strings 2 or what ever it is". I'd hope you get this.



    here's the current code:

    Code:
    System::Void Form1::timer1_Tick(System::Object^  sender, System::EventArgs^  e)
    {
        timer1->Enabled = false;
        timer1::Stop();
    
        try
        {
            String ^URL1 = "http://www.mysite.com/myscript.php?user=test&pass=test";
    	HttpWebRequest ^request1 = safe_cast<HttpWebRequest^>(WebRequest::Create(URL1));
    	HttpWebResponse ^response1 = safe_cast<HttpWebResponse^>(request1->GetResponse());
    	StreamReader ^reader1 = gcnew StreamReader(response1->GetResponseStream());
    	String ^str1 = reader1->ReadToEnd();
    	String ^pattern1 = "(<p id='mystrings1'>(.*?)</p>)";
    	MatchCollection ^matches1 = Regex::Matches(str1, pattern1);
    
    	for each (Match ^x1 in matches1)
    	{
    		ListViewItem ^item1 = gcnew ListViewItem("",1);
    		item1->SubItems->Add(x1->Value->ToString()->Replace("<p id='mystrings1'>", "")->Replace("</p>", ""));
    		listView1::Items->AddRange(gcnew array<ListViewItem^>{item1});
    		listView1->CheckBoxes = true;
    	}
        }
        catch (Exception ^ex)
        {
        }
    }

    If you know how to tick the checkboxes for each listviewitem in the listview on the same line as the "enabled" strings, i would be very grateful.

    if you aren't sure what i means then take a look on the screenshot and get back to me if you get it.

    php page
    http://img840.imageshack.us/img840/7051/phppage.jpg


    my listview
    http://img819.imageshack.us/img819/133/listview.jpg



    hope you can be able to help me with this.

    Thanks,
    Mark

  5. #5
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    Like i said, read the docs, if that is the relevant class, if not then sorry I have no direct knowledge of what you are writing and it would take some study.

    Looking at the second image of the table it seems that the class documents i pointed you to are what you need to investigate. Good documentation is great, it tells you all about what your object can do, and if you understand what you are doing then you can easily write what you need after a little reading.
    Last edited by rogster001; 04-08-2012 at 05:19 AM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. timer.tick huh?
    By Rune Hunter in forum C# Programming
    Replies: 7
    Last Post: 04-03-2005, 11:12 AM
  2. tick- tack- toe
    By ronenk in forum C Programming
    Replies: 4
    Last Post: 06-23-2004, 04:33 AM
  3. Tick-based time ?
    By Korhedron in forum C++ Programming
    Replies: 2
    Last Post: 07-11-2003, 05:36 AM
  4. Tick Please
    By C++Nerd in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2002, 12:33 AM
  5. timer tick algorithms
    By Mohsinzb in forum C Programming
    Replies: 1
    Last Post: 03-27-2002, 12:58 PM