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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:41:29+00:00 2026-06-05T21:41:29+00:00

I have a datagridview, and it loads information from db. However, at run time,

  • 0

I have a datagridview, and it loads information from db. However, at run time, I want to allow a user to update a cell(which is readonly by default) but I am not able to do this, I need to do this because all the changes are saved in db but if I reload it it, some color style etc will be gone, therefore I want to only reload from db at request and make a change to the text of a read only col, please guide.

Thanks

  • 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-05T21:41:31+00:00Added an answer on June 5, 2026 at 9:41 pm

    This is the actual Question of the user

    I have a column in datagridview, which by default(I dont set it readonly anywhere in code) readonly. It is coming from a dataset which gets data from a stored procedure, this particular field is a calculated one, so there is no column in the table for it. All other fields which are in table I can manipulate, except for this one. I need to (for only display purposes in datagridview) change this columns value at run time which is causing a readonly error

    This is the Answer which solved the user issue.

    After you have read the data from dataset, the column for which it is saying read-only, try doing this – ds.Tables[0].Columns["Your New Column"].ReadOnly = false;

    Read the comments below for more clarity please.

    Ignore the answer & code below because the actual question of the user is in the comments below which I have written above. User should modify his question. Its totally wrong and misleading

    Add a Winforms Project, Drop a DataGridView and a Button. Add a click Handler to the Button.

    Add a column in DataGridView and name the DataProperty of the column as “Name” in the Designer. Mark it as Read-Only. The column DataPropertyName must match with fields in database. I have a class called Books with a Property called Name. Hence it should be called Name in this case.

    Copy Paste the code below and Hit F5.

    Click the Button to update the read-only column value.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                List<Book> books = new List<Book>();
                books.Add(new Book() { Name = "C#" });
    
                InitializeComponent();
    
                dataGridView1.AutoGenerateColumns = false;
                dataGridView1.DataSource = books;
                dataGridView1.Refresh();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                dataGridView1[0,0].Value = "Winforms";
            }
       }
    
        public class Book
        {
            public string Name { get; set; }
        }
    }
    

    DataGridView Designer Code for Reference:-

    // 
                // dataGridView1
                // 
                this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
                this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
                this.Column1});
                this.dataGridView1.Location = new System.Drawing.Point(42, 91);
                this.dataGridView1.Name = "dataGridView1";
                this.dataGridView1.Size = new System.Drawing.Size(270, 157);
                this.dataGridView1.TabIndex = 1;
                // 
                // Column1
                // 
                this.Column1.DataPropertyName = "Name";
                this.Column1.HeaderText = "Name";
                this.Column1.Name = "Column1";
                this.Column1.ReadOnly = true;
    
    • 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 loads data from mdb Access table The grid only
I have a form with a DataGridView and I want to load data from
I have datagridview with paging enabled. But when I want to move from page
I have datagridview which fills data from database, there are columns where I have
I have a problem when I want to transfer data from Excel to dataGridView
I have a datagridview on a form, and I want a specific cell in
I have datagridview with checkbox column, but I want, that some of the columns
I have a datagridview which is editable. I have a textbox below it. I
I have a Winforms DataGridView in my application. When the user selects a row
I have a DataGridView where I show some information on the Web, everything works

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.