Khushal
Khushal

Reputation: 41

how to Disable Default Keyboard handling in the Windows Forms DataGridView control in c# framework 4.7

I'm using 4.7 .NetFramework. I'm Trying to Press F3 on DataGridView Control and it takes as Sorting GridData. So i want to disable this Key.

Upvotes: 0

Views: 811

Answers (2)

raulmd13
raulmd13

Reputation: 191

You have to create your own customized datagridview.

class MyDataGridView:DataGridView  
{
      protected override void OnKeyDown(KeyEventArgs e)
      {
         //Here you have to manage what you want to do with the keys.
      }
}

Upvotes: 0

Viewed
Viewed

Reputation: 1413

The sort mode for each text box column is specified through the SortMode property of the column. By default is set to Automatic. That why press F3 worked. Set SortMode property to NotSortable value.

dataGridView.Columns["ColumnName"].SortMode = DataGridViewColumnSortMode.NotSortable;

More information look at DataGridViewColumnSortMode and article.

Upvotes: 1

Related Questions