943,973 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 5792
  • C# RSS
Sep 21st, 2007
0

DataGridView

Expand Post »
hi
i have created one UI application using c#. i want to use PageDown Keys for navigate between rows, but when i press PageDown keys datagridview select last row.
How can i do this?
thanks in advance
my code:
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.PageDown)
{
int cRow=dataGridView1.CurrentRow.Index;
cRow += 1;
dataGridView1.CurrentCell = dataGridView1.Rows[cRow].Cells[0];

}
}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
faranak is offline Offline
13 posts
since Sep 2007
Sep 21st, 2007
0

Re: DataGridView

you maybe select another control!!
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 22nd, 2007
0

Re: DataGridView

No, I want to use this control
Reputation Points: 10
Solved Threads: 0
Newbie Poster
faranak is offline Offline
13 posts
since Sep 2007
Sep 22nd, 2007
0

Re: DataGridView

I mean do u sure the gridview is selected in other meaning the focused control
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 24th, 2007
0

Re: DataGridView

hi,

try using the SelectionChanged event of the datagridview. you can use arrow keys to navigate through the records and this event gets fired automatically.


Hope this helps.


Regards

Exelio
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Exelio is offline Offline
57 posts
since Aug 2006
Sep 25th, 2007
0

Re: DataGridView

I assume what you want to do is trap the Page Down key and use it for navigating the datagridview. The problem in your code is that you are not telling the datagridview that you have aleady handle the key press.

Let it know that you have taken care of the key press by setting the Handled property to true.
If using KeyPress then assign the KeyPressEventArgs e ... e.Handled = true;
if using KeyDown then assign the KeyEventArgs e ... e.handled = true;

This prevents the event from going into the internal key event handler of the DataGridView.
Reputation Points: 69
Solved Threads: 75
Posting Pro in Training
JerryShaw is offline Offline
465 posts
since Nov 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: C# codes
Next Thread in C# Forum Timeline: Printer Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC