How can I run code in a background thread and still access the UI?

While I’m glad you found a solution, I advise against using Application.DoEvents() because it is bad practice. Please see this blog post: Keeping your UI Responsive and the Dangers of Application.DoEvents. Simply put, Application.DoEvents() is a dirty workaround that makes your UI seem responsive because it forces the UI thread to handle all currently available … Read more

How to show soft-keyboard when edittext is focused

To force the soft keyboard to appear, you can use EditText yourEditText= (EditText) findViewById(R.id.yourEditText); yourEditText.requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT); And for removing the focus on EditText, sadly you need to have a dummy View to grab focus. To close it you can use InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0); This works … Read more

Panel not getting focus

The Panel class was designed as container, it avoids taking the focus so a child control will always get it. You’ll need some surgery to fix that. I threw in the code to get cursor key strokes in the KeyDown event as well: using System; using System.Drawing; using System.Windows.Forms; class SelectablePanel : Panel { public … Read more

Which HTML elements can receive focus?

There isn’t a definite list, it’s up to the browser. The only standard we have is DOM Level 2 HTML, according to which the only elements that have a focus() method are HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement and HTMLAnchorElement. This notably omits HTMLButtonElement and HTMLAreaElement. Today’s browsers define focus() on HTMLElement, but an element won’t actually take … Read more