RE: Property grid navigation by v-jetan
v-jetan
Sat Aug 07 03:20:07 CDT 2004
Hi John,
Based on my understanding, you want to add the Tab key navigation in
WinForm PropertyGrid control.
======================================
To get this done, we may customize a PropertyGrid intercept the Tab keydown
message and translate it into next grid cell selection operation.
We may override PropertyGrid.ProcessKeyPreview method, and determine the
Tab key down message.
To get the next grid item reference, we can first get the selecteditem's
parent grid item's reference, then loop through its child items, the next
reference after the selected item is what we need.
Code snippet lists below:
public class MyPropertygrid : System.Windows.Forms.PropertyGrid
{
const int WM_KEYDOWN=0x100;
const int VK_TAB=0x09;
protected override bool ProcessKeyPreview(ref Message m)
{
if(m.Msg==WM_KEYDOWN)
{
if(m.WParam==(IntPtr)VK_TAB)
{
GridItem gi=this.SelectedGridItem;
GridItem p_gi=gi.Parent;
int i;
for(i=0;i<p_gi.GridItems.Count;i++)
{
if(p_gi.GridItems[i]==gi)
{
break;
}
}
p_gi.GridItems[i+1].Select();
return true;
}
}
return base.ProcessKeyPreview (ref m);
}
}
=====================================
Please apply my suggestion above and let me know if it helps resolve your
problem.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.