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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:04:04+00:00 2026-06-14T00:04:04+00:00

I have a DataGridView and I’m binding it to a BindingList<KeyValuePair<string, float>> . Here’s

  • 0

I have a DataGridView and I’m binding it to a BindingList<KeyValuePair<string, float>>. Here’s the relevant part of the code:

        dgv.AutoGenerateColumns = false;

        DataGridViewTextBoxColumn firstColumn = new DataGridViewTextBoxColumn();
        firstColumn.DataPropertyName = "Key";
        firstColumn.HeaderText = "First Column";

        DataGridViewTextBoxColumn secondColumn = new DataGridViewTextBoxColumn();
        secondColumn.DataPropertyName = "Value";
        secondColumn.HeaderText = "Second Column";
        secondColumn.ReadOnly = false;
        secondColumn.ValueType = typeof(float);

        dgv.Columns.Add(firstColumn);
        dgv.Columns.Add(secondColumn);
        dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        dgv.MultiSelect = false;
        dgv.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2;
        dgv.ReadOnly = false;

        _bindingList = new BindingList<KeyValuePair<string, float>>(_someList);
        dgv.DataSource = _bindingList;

But the second column is still not editable. What should I do to make the second column editable and the first one not?

Edit: I’d like the changes to be reflected on the BindingList instance itself.

Edit 2: I have added this line in the end of the code and now I’m getting an error:

        dgv.Columns[1].ReadOnly = false;

I get this error:

DataGridView column bound to a read-only field must have ReadOnly set to True.

Edit 3: The problem seems to be that I’m using KeyValuePairs in my list.

  • 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-06-14T00:04:05+00:00Added an answer on June 14, 2026 at 12:04 am

    The problem turns out to be that the Key and Value properties of the KeyValuePair class are read-only. The solution is to create a new class that has public setters to represent the data.

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

Sidebar

Related Questions

I have a DataGridView which I am binding like so: companies = new BindingList<Company>(PersistenceManager.Instance.RetrieveAll<Company>(SessionAction.BeginAndEnd));
I have a DataGridView with four Columns and need to crate a multiline string
hi i have datagridview name data1, and binding data to data1 from database, when
I have a datagridview which im binding DataTable to. What I want do is
I have a DataGridView that I'm binding to a DataTable. The DataTable is a
i have a datagridview row, containing three string values. These values should be looked
I have a DataGridView with an edit option. I did my code, but this
I have DataGridView on my form and I'm trying to color cell. Here's the
I have DataGridView with two columns. The first column is TextBoxCol(DataGridViewTextBoxColumn) and the Second
I have DataGridView and I set DataSource of datagridview by using DataTables. DataTable dt

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.