Disable focus on controls?

  • Thread starter Thread starter brianbasquille
  • Start date Start date
B

brianbasquille

Hello all,

Simple enough question here, i think!

I have a form which i want to work exclusively with the mouse but
pressing up and down gives focus to two buttons which i have on the
form?

How could i disable focus entirely?

Regards,

Brian
 
Set the KeyPreview true... and just ignore any key events that you don't
want to in the KeyDown event.. or you could use the KeyPress Event..

Vijay
 
Cheers for that Vijay but that didn't work. I put the following in my
form designer:

this.KeyPreview = true;

And under the KeyDown event, i have:

private void MovieListForm_KeyDown(object
sender,System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Down)
{
this.MovieListPage.CurMenuItem++;
}
else if(e.KeyCode == Keys.Up)
{
this.MovieListPage.CurMenuItem--;
}
}

Yet focus is still given to the buttons when i press the Up and Down
arrow.

Any other suggestions?

Regards,

Brian
 
uhm... your piece of code in KeyDown is interesting.. I have not the same
code here.. but something similar and it works for me... Ok I understand
there is a reason you are doing this, but I don't see anything like ignoring
the Up and Down arrow key..so try this.

if ( e.KeyCode == Keys.Up
|| e.KeyCode == Keys.Down)
{
e.Handled = false;
return;
}

that seems to work.. for me here..

Vijay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top