pavan
pavan

Reputation: 149

Override datagridview class

I want to override the datagridview class like override bool ProcessDialogKey and ProcessDataGridViewKey. in which form should i write this code to work?

Upvotes: 0

Views: 2049

Answers (1)

Jay Riggs
Jay Riggs

Reputation: 53593

I'm not sure what you mean by which form you should use, but you can extend a DataGridView in a class, like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MyTest
{
    class MyDataGridView : DataGridView
    {

        protected override bool ProcessDialogKey(Keys keyData) {
            // Your implementation here.
        }

        protected override bool ProcessDataGridViewKey(KeyEventArgs e) {
            // Your implementation here.
        }
    }
}

This code create a new class, MyDataGridView which inherits from the standard Winform DataGridView class. You can read more about inheritance here.

Upvotes: 2

Related Questions