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 7034217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:09:32+00:00 2026-05-28T01:09:32+00:00

I have a listview that serves as a user-settings table. Each key is the

  • 0

I have a listview that serves as a user-settings table. Each key is the setting, each subitem of the key is the value, and everything is nice and dandy.

I would like to be able to link this table of sorts to a checkbox. If the setting is true, the checkbox is checked, if it’s false, the checkbox isn’t checked. Let’s call the setting “settingChecked”.

The listview looks like:

|    Setting     |  Value |

| settingChecked |  true  |

Something along those lines anyway… When the user inputs a setting, I have a function run to check the value of it and check the checkbox accordingly. Likewise, when they click the checkbox, I need to change the setting’s value in the table. Problem being that the settings aren’t case-sensitive. So if they put:

|    Setting     |  Value |

| sEttIngChecked |  true  |

I wouldn’t be able to find the value with ListView1.Items[“settingChecked”]. The way I wrote it (I’m new to C#, so cut me some slack on this front) is to iterate through each element of the listview and check its lowercase text and the lowercase text of the setting. The code looks blocky and inefficient and doesn’t seem right. I could, of course correct the casing upon adding the setting, but I would like to let the users have the freedom to type as they please.

So, this arises two questions. First, how does the system find the member of a list by its key? Is there a reference of keys to their addresses for each list? Second, how do I find the element by its key, independent of case?

The best I can think of, in replace of the iteration, is a class with a Dictionary that references the item in the listview. This seems like it would also take up more resources than the program should.

Finally, how do I get rid of the annoying third-wheel of an extra column in the listview? Is the listview not meant to be used as a table? Is there a better tool to use?

edit: I’m aware I can do something like:

listView1.Items.Cast<ListViewItem>().Where(x => x.Text.ToLower() == "settingchecked").ToArray()[0];

but that seems like the same thing is a more concise form.

  • 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-28T01:09:33+00:00Added an answer on May 28, 2026 at 1:09 am

    I’m not sure who, but someone had posted an answer not too long ago saying something about setting the key as lowercase, which made me realize that the text doesn’t have to be the same as the key. Though I had no idea how the key was set, I did a little testing and found out it’s the name of the listviewitem.

    Anyway, something like:

    void AddSetting(string settingName, string value, ListView table) {
        ListViewItem setting = new ListViewItem(settingName, value);
        setting.Name = settingName.ToLower();
        table.Items.Add(setting);
    }
    string GetSettingValue(string settingName, ListView table) {
        if (table.Items.ContainsKey(settingName.ToLower())) {
            return table.Items[settingName.ToLower()].SubItems[1].Text;
        }
        return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview that is binded to a ThreadSafeObservableCollection. The background of each
I have a ListView that has a FileUpload control and a button in each
I have this ListView that displays a custom user control. The custom user control
I have ListView that has the following EditItemTemplate: <EditItemTemplate> <tr style=> <td> <asp:LinkButton ID=UpdateButton
I have a ListView that is set up with a MinHeight and a MaxHeight.
I have a ListView that I am populating with items from an ObservableCollection .
A have a ListView that is rendered with multiple items. Now I want to
I have a ListView that is populated using an XML file. However, I want
I have a WPF ListView that is bound to a BindingList<T>. The binding works
I have a ListView control that is in FullRowSelect mode, MultiSelect off and using

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.