473,394 Members | 1,811 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,394 software developers and data experts.

Cannot assign to 'Focus' because its a 'Method Group in C#

I am trying to keep focus on a button. How do I do that?

private void cmdRead_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.F24)
{
StartReading();
}
}


Thanks,

dtittle
Skype: <removed>
Oct 14 '08 #1
8 11188
akshaycjoshi
153 100+
Use the Focus() method of the control to set focus on it.
Oct 14 '08 #2
As the name (newbie) applies, how do I do that?
Oct 14 '08 #3
I'm trying to keep focus on a button after I press it. The TabIndex is set to zero. I've heard some stuff about using the Focus() method of the control but I'm not sure what to do with it. Do any of you all have an example I could look at?

CODE
private void cmdRead_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.F24)
{
StartReading();
}
}
/CODE

I'm not sure if this is where the code would go either.
Oct 14 '08 #4
joedeene
583 512MB
Well drag a timer to your form in the designer view, and in the code view type in

Expand|Select|Wrap|Line Numbers
  1. private void timer1_Tick(object sender, EventArgs e)
  2.         {
  3.             button1.Focus();
  4.         }
  5.  
  6.         private void Form1_Load(object sender, EventArgs e)
  7.         {
  8.             timer1.Interval = 500;
  9.             timer1.Start();
  10.         }
but instead of button1 put the name or control you want to have focused, and change the timer's interval rate to one that suits you.

joedeene
Oct 14 '08 #5
Plater
7,872 Expert 4TB
When you say "focus" do you mean you want to watch for when a certain key on the keyboard is pressed (as your code would suggest), or do you want the point of concentration to always be on a certain control?
Oct 14 '08 #6
Curtis Rutland
3,256 Expert 2GB
Threads Merged.

Please don't double post your questions. If you made a mistake and need to change your question, you can click the Edit button to edit your post, or you can post your corrections in a reply to your original thread. If you can't find your original thread, click the "My Subscriptions" link near the top of the page. If you feel that your question has been overlooked, post a reply to it to "bump" it back to the top of the forum. We ask that you do this only once every 24 hours.

So there is no reason to double post. It makes it hard on the Experts and you to keep track of what help you've already been given.

Also, the Cafe is not the place for technical questions. Please post your questions in a single appropriate forum. If you don't know which, choose one, and we'll move it for you.

Also, I have removed your Skype ID from your signature on this post. It is against our Signature Guidelines:

From the FAQ (Things that are unacceptable in a signature)
Your own or anyone else’s email address (this is for your own security) or other personal contact details
MODERATOR
Oct 14 '08 #7
Sorry all, I am trying to keep focus on a button that is remapped to a virtual key. when I press the trigger ((PSION WORKABOUT PRO) device with a trigger grip). I want to fire the RFID reader. It works the first time; however, after reading tag and displaying the output, the focus leaves the read button, So yes, Plater I am trying as you asked, to keep the focus to on the read button at all times.
Oct 14 '08 #8
akshaycjoshi
153 100+
private void cmdRead_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.F24)
{
StartReading();
buttonname.Focus();
}
}

There is nothing difficult about using this method then why is it causing so much probels for you.
Anyways consult the SDK for more information.
Oct 15 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: bradwiseathome | last post by:
I focus on controls in a web form like this: <script language="javascript"> var focusControl = null; if (document.getElementById) focusControl = document.getElementById('txtArea1'); else if...
3
by: Brian Henry | last post by:
Hi, I have a bunch of forms in a DLL that I call from my main application. The one form is a login form, and I have the tab order set in the order I want it (password box first, then ok button...
4
by: Johannes Kiehl | last post by:
Hi group, I've been losing most of my remaining hair today, trying to track down a problem with IE6.0 (builds: .2600 and XP SP 2). I set the border-width of form input fields to 1px via...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
2
by: Chino | last post by:
Hi guys, Sorry but i am new to ASP.Net and C# so please bear with my pleb questions. I have the following in a C# class which is being inherited by my ASP.Net page. In this class i have an...
7
by: Dave Booker | last post by:
I am using a WebBrowser object in my .NET 2.0 application, but it is not shown to the user. Every time a timer event triggers it to perform a m_WebBrowser.Navigate() I get that classic IE 'click'...
5
by: Matt B | last post by:
I know this is a bit of nonstandard behavior, but I would like the Enter key to move focus through a group of radiobuttons without selecting them. The user would then have to use Space or actually...
2
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.