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

  • Home
  • SEARCH
  • 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 3596900
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:02:56+00:00 2026-05-18T20:02:56+00:00

I am using a drop-down list in DataGridView control, but the problem is that

  • 0

I am using a drop-down list in DataGridView control, but the problem is that for the first time I click the drop-down, it takes two clicks to drop down the list and show, but afterwards it works fine.

 private void ViewActiveJobs_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex>=0)
            {
                jobCardId = int.Parse(ViewActiveJobs.Rows[ViewActiveJobs.CurrentCell.RowIndex].Cells["Job Card Number"].Value.ToString());
                RegNo = ViewActiveJobs.Rows[ViewActiveJobs.CurrentCell.RowIndex].Cells["Registeration Number"].Value.ToString();
                SelectedRow = e.RowIndex;                
            }
        }

        private void ViewActiveJobs_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            try
            {
                ComboBox cbox = (ComboBox)e.Control;
                cbox.SelectedIndexChanged -= new EventHandler(comboBOX_SelectedIndexChanged);
                cbox.SelectedIndexChanged += new EventHandler(comboBOX_SelectedIndexChanged);
            }
            catch(Exception)
            {
            }
        }
        private void comboBOX_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox combo = sender as ComboBox;
            string str = combo.SelectedIndex.ToString();
           if (combo.SelectedIndex ==1)
                pdf = new MakePDF(jobCardId,RegNo);
           if (combo.SelectedIndex == 2)
           {
               PdfJobCard = new MakePDFJobCard(jobCardId);
           }
            if (combo.SelectedIndex == 3)
           {
               if (MessageBox.Show("Are you Sure you want to Close Job Card ?", "Are you Sure",
                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
               {
                   cmd = new SqlCommand();
                   cmd.Connection = con;

                   cmd.Parameters.Add("@jCard", SqlDbType.VarChar).Value = jobCardId;
                   cmd.Parameters.Add("@stat", SqlDbType.VarChar).Value = "Closed";
                   cmd.CommandText = "UPDATE JobCard SET status = @stat WHERE Id = @jCard";

                   try
                   {
                       cmd.ExecuteNonQuery();
                       ViewActiveJobs.Visible = false;
                       ViewActiveJobs.AllowUserToAddRows = true;
                       ViewActiveJobs.Rows.RemoveAt(SelectedRow);
                       //ViewActiveJobs.Visible = true;
                   }
                   catch (Exception c)
                   {
                       MessageBox.Show(c.Message);
                   }
               }
           }
        }
  • 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-18T20:02:56+00:00Added an answer on May 18, 2026 at 8:02 pm

    This is the expected behavior. The first click is necessary to set focus to the combo box. The second click shows the drop-down list, once the control has the focus.

    Does that answer your question? Or do you feel some need to override the default behavior? Before answering yes, consider keyboard users and those navigating from cell-to-cell in your DataGridView using the arrow keys.

    If the answer is still yes, see my answer to this related question. Essentially, you need to make sure that the EditMode property of your DataGridView control is set to “EditOnEnter”, and then virtually “press” the F4 key in the EditingControlShowing event handler to drop down the combo box.

    As an aside: You should not have empty Catch blocks in your code! Fix that.

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

Sidebar

Related Questions

I am using a Drop Down List for selecting some options. Everything works fine,
I've got a dropdown list that is being populated via a webservice using ASP>NET
pretty much what the title says. I am using an Ajax Drop Down as
How can I restore a mysql database that was dropped using a drop database
I am using a dropdown to populate a textbox. But if preferred value is
Using jquery how do I focus the first element (edit field, text area, dropdown
I am using CaptureMouse() during a drag and drop operation to make sure I
I'm using YUI to add drag drop support to a div. It also responds
i have a DataGridView responsible for showing a bit of data and two of
I am using a Datagridview (unbounded mode) and I have selected enable adding in

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.