Live Chat Icon For mobile
Live Chat Icon

In my datagrid, if I press tab to enter a column using a derived columnstyle, the column does not receive focus. Why

Platform: WinForms| Category: Datagrid

This behavior can be seen when you embedded a control like a textbox or combobox in your derived GridColumnStyle. If you press the tabkey slowly, you may see the cell get focus on the downkey and the cell lose focus on the upkey. One way to avoid this problem is to subclass the embedded control, and override its WndProc method, ignoring the KeyUp.

public class MyCombo : ComboBox
         private const int WM_KEYUP = 0x101;

         protected override void WndProc(ref System.Windows.Forms.Message m)
                  if(m.Msg == WM_KEYUP)
                           return;  //ignore the keyup
                  base.WndProc(ref m);

Public Class MyTextBox
	Inherits TextBox
	Private WM_KEYUP As Integer = &H101
	Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
		If m.Msg = WM_KEYUP Then
			Return ’ignore the keyup
		End If
	End Sub ’WndProc
End Class ’MyTextBox

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.