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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:28:30+00:00 2026-05-17T02:28:30+00:00

Software I use: C#, VS-2005. I have a populated combobox in datagridview. I have

  • 0

Software I use: C#, VS-2005.

I have a populated combobox in datagridview. I have noticed that when the datagridview property RowHeaderVisible is set to false then no keydown event is fired on editing control. But when I set RowHeaderVisible to true, the keydown event works fine.

So, I know that the RowHeaderVisible property set to true will work. But there is no need to set it to true as per my requirement.

I want to know the reason for this behavior, and how to overcome it.

My Code Is :

private void Form1_Load(object sender, EventArgs e)

{          
        string consstr = "server=.;initial   
        catalog=mydatabase;uid=myuserid;pwd=mypassword";
        SqlConnection conn = new SqlConnection(consstr);
        conn.Open();
        string sql = "select accname from AccountMast";
        SqlDataAdapter dap = new SqlDataAdapter(sql, conn);
        DataSet ds = new DataSet();
        dap.Fill(ds);
        DataTable dt = new DataTable();
        DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
        dataGridView1.Columns.Add(cmb);
        cmb.DataSource = ds.Tables[0];
        cmb.DisplayMember = "accname";
        cmb.ValueMember = "accname";
        dt.Columns.Add("AMOUNT", typeof(decimal));
        dataGridView1.DataSource = dt;
        dataGridView1.Columns[0].Width = 300;
        dataGridView1.Columns[1].Width = 143;
        dataGridView1.Columns[1].DefaultCellStyle.Format = "f2";
    }
   private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Alt == true && e.KeyCode == Keys.C) 
        {
            Form2 f2 = new Form2();
            f2.Show();
         }
    }

The above code is represent entry point. I mean user enter the data on it. I have populate combobox in datagridview with database of sql. The combobox having list of account name. user select it as per their demand and than enter data on column of amount and save it.

That’s all. but there is a problem you can see it. as per my comment lying below the “tergive’s” answer.

  • 1 1 Answer
  • 1 View
  • 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-17T02:28:30+00:00Added an answer on May 17, 2026 at 2:28 am

    Here is an alternate form using ProcessCmdKey on the form instead of using the custom DGV:

    using System;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;
    
    class Form1 : Form
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    
        DataGridView dgv;
    
        public Form1()
        {
            Text = "Form1";
    
            dgv = new DataGridView();
            dgv.Dock = DockStyle.Fill;
            DataGridViewComboBoxColumn dgvColumn = new DataGridViewComboBoxColumn();
            dgvColumn.HeaderText = "Header";
            dgvColumn.DataSource = new string[] { "One", "Two", "Three", "Four" };
            dgv.Columns.Add(dgvColumn);
            Controls.Add(dgv);
    
            Button button = new Button();
            button.Text = "Place holder";
            button.Dock = DockStyle.Top;
            Controls.Add(button);
        }
    
        [DllImport("user32.dll")]
        private static extern bool IsChild(IntPtr hwndParent, IntPtr hwndChild);
    
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if ((keyData & (Keys.Alt | Keys.C)) == (Keys.Alt | Keys.C))
            {
                if (dgv.Handle == msg.HWnd || IsChild(dgv.Handle, msg.HWnd))
                {
                    Form form = new Form();
                    form.Text = "Form2";
                    form.Show(this);
                    return true;
                }
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We use a software which uses Sql server 2005 as back-end. The problem is
A stupid third-party software that we use stores datetime as varchar for some good
My company's proprietary software generates a log file that is much easier to use
We currently use SQL Server 2005 Enterprise for our fairly large application, that has
We have some software we use internally which is released via ClickOnce from VS
net application. .exe generated is sufficient to use software. since I have 700 MB
I have the following software installed on the machine: Microsoft SQL Server Express 2005
Regex newbie here. There's a (broken) plugin for the forum software I use that
I'm beginning to work on mailing-list software we use internally (EDIT: though we send
I am interested in an array of software ideas and use more than one

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.