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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:14:13+00:00 2026-05-21T09:14:13+00:00

I have a mydatagridview class which inherits from the built-in DataGridView control, as shown

  • 0

I have a mydatagridview class which inherits from the built-in DataGridView control, as shown below:

public class mydatagridview : DataGridView 
{
    protected override bool ProcessDataGridViewKey(KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter) 
        {
            this.ProcessTabKey(e.KeyData);
            return true;
        }
        return base.ProcessDataGridViewKey(e);
    }

    protected override bool ProcessDialogKey(Keys keyData)
    {
        if (keyData == Keys.Enter) 
        {
            this.ProcessTabKey(keyData);
            return true;
        }
        return base.ProcessDialogKey(keyData);
    }
}

Now I want to utilize it in my main class:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
}

I want to Utilize myDatagridview with Datagridview1 of : public partial class Form1 : Form

How can I do this?

  • 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-21T09:14:14+00:00Added an answer on May 21, 2026 at 9:14 am

    You need to create an instance of your custom control class, and then add that instance to your form’s Controls collection. For example:

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
    
            // Create an instance of your custom control
            mydatagridview myDGV = new mydatagridview();
    
            // Add that instance to your form's Controls collection
            this.Controls.Add(myDGV);
        }
    }
    

    Of course, you could also do the same thing from the Designer. It will automatically insert code very similar to that shown above inside the InitializeComponent() method.

    If your custom control doesn’t show up in the Toolbox automatically after you’ve rebuilt your project, make sure that you’ve enabled toolbox auto-population:

    1. From the "Tools" menu, select "Options".

    2. Expand the "Windows Forms Designer" category.

    3. Set the "AutoToolboxPopulate" property to True.

      Set the AutoToolboxPopulate to True in VS Options

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

Sidebar

Related Questions

I have a control which extends the DataGridView control. I am overriding the ProcessDialyKey
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I have a datagridview which we will call dataGridViewExample. My object (the uncommon datatypes
I am struggling with the WinForms DataGridView. I have a class, that I use
My DataGridView needs to support a number of types and these types may have
So I have a datagridview. Normally I can create a bindinglist of my object
In C#, I have a table displayed using a DataGridView . The table is
I have a DataGridView that I want to use to store generic data. I
I have a query as such (simplified): var q = from t in _entities.Table
I have a winForms DataGridView bound to a List<MyObjectType> . My problem is that

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.