473,408 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

working with DataGrid and TextBox

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
Nov 17 '05 #1
1 3963
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

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andrea Trevisan | last post by:
That's a revival of a known thing I suppose.I hope it's useful. My problem was: I want to have a DataGrid with two Template columns: first with TextBox,second with Button.I want to fire an event...
0
by: shamila | last post by:
</asp:label><asp:datagrid id="DataGrid3" runat="server" cssclass="DataGrid" showfooter="True" onupdatecommand="DataGrid3_Update"ondeletecommand="DataGrid3_Delete" oneditcommand="DataGrid3_Edit"...
1
by: tshad | last post by:
I can't seem to get insert into a DataGrid to work. I am using an example from the net and made changes to work on my computer. The grid comes up fine. The edit boxes in the footer are there. ...
9
by: tshad | last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled? I have a bunch of DataGrids that get displayed nested inside a DataList. The datagrid looks like: ...
8
by: tshad | last post by:
I cannot seem to get the asp:textbox to use classes. Style works fine. I am trying to set the textbox to act like a label in some instance so it doesn't have a border, readonly and the background...
1
by: Schultz | last post by:
Hi, i am trying to make a fully editable dataGrid and was using the "Top Ten Questions about the DataGrid Control" article in the MSDN Library as a guide. The following is my current vb code. I ran...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
2
by: jose.mendez22 | last post by:
In my code I create a sqlDataAdapter that which contains a simple select command using the Northwind DB (SELECT top 15 customerID, companyName, contactName, contactTitle From Customers). I...
1
by: bhaktija | last post by:
form is created which contains textboxes , labels , datacombos and it uses 4 tables from the database there is one datacombo which displays names of menuitems contained in menuitem table.when...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.