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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:01:31+00:00 2026-05-23T05:01:31+00:00

I have a datagridview that is bound to a SQLite database. Now, I wish

  • 0

I have a datagridview that is bound to a SQLite database. Now, I wish to modify some fields in the datagridview.

There are 4 TEXT columns – Timestamp, Message, Type , Hash.
Now I find a row, I want to right click it.. And it should have to option – “include” .. So, when i click include in the context menu, the Type column of my DGV should change to “include” from whatever it previously was… (I don’t want it be enabled to edit.. I just want it to change within the program) How do i get the index where I have clicked and access that particular cell to modify it??

  • 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-23T05:01:32+00:00Added an answer on May 23, 2026 at 5:01 am

    This code does what you want:

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
    
            BindingList<User> users = new BindingList<User>();
            users.Add(new User(){Name = "Fred", Included = "False", Title="Mr"});
            users.Add(new User(){Name = "Sue", Included = "False", Title="Dr"});
            users.Add(new User(){Name = "Jack", Included = "False", Title="Mr"});
    
            dataGridView1.DataSource = users;
        }
    
    
        private void dataGridView1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                DataGridView.HitTestInfo hit = dataGridView1.HitTest(e.X, e.Y);
    
                if (hit.rowIndex >= 0)
                {
                    dataGridView1.ClearSelection();
                    dataGridView1.Rows[hit.RowIndex].Selected = true;
                    contextMenuStrip1.Show(this.dataGridView1, new Point(e.X, e.Y));
                }
            }
        }
    
        private void includeToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            // Included was the name of the column to change in my example code,
            // you could also use the index of the column if you know it.
            dataGridView1.SelectedRows[0].Cells["Included"].Value = "Included";
        }
    }
    
    public class User
    {
        public string Name { get; set; }
        public string Title { get; set; }
        public string Included { get; set; }
    }
    

    I couldn’t think of a better method of informing the context menu which row was selected than actually using the selected row property of the DataGridView – you could also store this in a class level field, but I don’t think that is quite as tidy.

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

Sidebar

Related Questions

I have a DataGridView that's bound to a DataSet. It has columns DateCreated, Weight,
I've got some Columns in a DataGridView that have their Binding property set to
I have a DataGridView bound to a DataTable that has 1+16 columns defined as
I have a datagridview which is bound to some data. One of the fields
I have a DataGridView that is bound to a DataTable, is there a way
I currently have a DataGridView bound to a LIST that contains 4 fields. The
I currently have a DataGridView bound to an sqlite database in c:\temp. I bind
I have a windows forms DataGridView that contains some DataGridViewComboBoxCell s that are bound
I have a DataGridView that is bound to a list of objects called BaseChange.
I have a DataGridView that is bound to a DataTable, it has a column

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.