Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7678493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:39:37+00:00 2026-05-31T17:39:37+00:00

I have a problem, that I can’t solve. I am writing an application that

  • 0

I have a problem, that I can’t solve.
I am writing an application that will help to change system proxy easily. It has a listView with some items. These items have checkboxes.
Logic of application demands that only one item can be checked at a time, so I have following code to make sure it works well:

    private void listView1_ItemChecked(object sender, ItemCheckedEventArgs e)
    {
        listView1.ItemChecked -= listView1_ItemChecked;
        foreach(ListViewItem item in listView1.Items)
        {
            if(item != e.Item)
            {
                item.Checked = false;
            }
        }
        listView1.ItemChecked += listView1_ItemChecked;
    }

Also my application needs to check some value in registry on it’s start and compare it’s text with my items in listView.
I am doing it like that:

    private void GetProxyFromRegistry()
    {
        RegistryKey SystemProxy = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings");
        try
        {
            string UsedProxy = SystemProxy.GetValue("ProxyServer").ToString();
            foreach (ListViewItem item in listView1.Items)
            {
                if (UsedProxy == item.Text + ":" + item.SubItems[1].Text)
                {
                    item.Checked = true;
                }
                else
                {
                    item.Checked = false;
                }

            }
        }
        catch (Exception exc) 
        {
            MessageBox.Show(exc.Message);
        }
    }

The problem is that none of the listView1.Items will be checked except last one when used.
I know that it’s because of listView1_ItemChecked(), but I do not know how to solve it the other way.
Can you help me find a solution how to either uncheck all other checkboxes, or find a workaround to make correct item be checked?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:39:39+00:00Added an answer on May 31, 2026 at 5:39 pm

    So starting with your ItemCheck event, it should be like this:

    void listView1_ItemCheck(object sender, ItemCheckEventArgs e)
    {
            if (e.currentValue == CheckState.Checked)
                return;
            foreach (ListViewItem item in listView1.Items)
            {
                if (item.Index != e.Index)
                {
                    item.Checked = false;
                }
            }
    }
    

    For the next issue, I’d suggest setting a breakpoint at this line of code here:

       if (UsedProxy == item.Text + ":" + item.SubItems[1].Text)
    

    When the breakpoint is hit (on the last index), check to see what’s different about that item in comparison to the others (look at case sensitivity, for instance).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a problem that i can't solve ! (sqlite3, but i think it
I have a strange problem that I can't seem to solve. I've quite a
I have a script that constantly segfaults - the problem that I can't solve
I have a weird date rounding problem that hopefully someone can solve. My client
So I have a problem that I can not figure out. I am writing
I have another problem that I can't solve I have a following code that
i have this problem that i can't solve for days now...here is my code.
I have a problem that I can't solve... In my Activity, I instantiate a
I have a little problem that I can't figure out how to solve. I
I have one problem in my application. the problem is that can i bind

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.