Hi,
We have a XamDataGrid containing a list of lots of people. The persons name appears in the first column, along with further details like e-mail address in other columns. The grid is sorted by the first column.
We would like it so pressing 'm' (for example), jumps to the first person whose name starts with 'm'.
I was surprised I couldn't see any other posts in the forum regarding this... I can no doubt get it to work but was wondering if anyone has implemented behaviour like this already they could share?
Cheers,Dave
Hi Alex,
I had to make a few tweaks so it handled group records, but that worked great thanks.
Dave
Hello Dave,
You can handle the PreviewKeyDown event on the XamDataGrid and make a quick search on the primary field of the XamDataGrid. Here is a small simple example of what I have in mind :
void xamDataGrid1_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (xamDataGrid1.ActiveCell!=null && xamDataGrid1.ActiveCell.IsInEditMode)
return;
else
Field primeField = xamDataGrid1.DefaultFieldLayout.PrimaryField;
if (primeField != null)
var firstObject = (from dr in xamDataGrid1.Records
where (dr as DataRecord).Cells[primeField].Value.ToString().StartsWith(e.Key.ToString())
select dr).FirstOrDefault();
if (firstObject != null)
(firstObject as DataRecord).IsActive = true;
xamDataGrid1.BringRecordIntoView(firstObject);
}