Hi Gidi,
what I would do is to inherit from the standard
System.Windows.Forms.TextBox so that you can capture the Command Key press
events, when you capture these events you can then have a reference to your
DataGrid and move it up and down accordingly i.e.
Assume you have an object called MyDataGridObject, you don't have to you can
do this a thousand and one ways but I just put it in to clarify the example.
class MyTextBox : TextBox
{
MyDataGridObject m_dg = null;
public MyTextBox() : base()
{
}
public MyDataGridObject SetMyDataGridObject
{
set
{
m_dg = Value;
}
}
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
//Tell the grid you pressed a key so that it can search to the correct
place
m_dg.KeyPressedByUser(e);
}
protected override void ProcessCmdKey(ref Message msg, Keys keyData)
{
if(keyData == Keys.Down)
{
m_dg.DownKeyPressed();
//need to return true to stop the down key being processed by the
textbox
return true;
}
if(keyData == Keys.Up)
{
m_dg.UpKeyPressed();
return true;
}
return base.ProcessCmdKey(ref msg, keyData
}
}
Hope that helps
Mark R Dawson
"Gidi" wrote:
Hi,
I have DataGrid table and TextBox in my form. the table contains names and i
use the textBox to enter letters to search specific customer. i want that the
user will be able to navigate the DataGrid with the UP and Down arrows while
the focus is on the TextBox and to mark the selected row.
for example, when the form loads,the focus is on the Textbox and the first
row is marked, the textbox is empty. i enter G and the table contains all the
names that begins with a G, the focus is still on the textbox and the first
name that begins with a G is marked, now, i saw that the name i look for is
at the 3rd row, so i want to navigate with the down arrow to this row, and
each time i press the down arrow i want the row i point at will be marked and
if the user will decide to add to the G also I, the focus will be back to the
textBox which will contain now GI.
how can it be done?
thanks