focus

How to prevent control from stealing focus?

We have a 3rd party control loaded in our C# WinForms app. When we call a method on this 3rd party ActiveX control, it asynchronously steals focus. For example: // This call causes 3rd party to spawn a thread and steal focus milliseconds later. foo3rdParty.DoSomething(); Is there a way to prevent a control from stealing focus? ...

How to achieve focus-reset to update BindingSource of TextBox before any action

I have observed some unexpected or at least not-perfectly-matching-my-needs behaviour of textboxes bound to textproperties when I can't use using UpdateTrigger=PropertyChanged for my binding. Probably it is not an issue with the textbox but will occur with other editors as well. In my example (source code attached), I have a WPF TabCont...

JavaScript - OffFocus event?

Hi What I want to do is display an input field with the text color black. Then when the person clicks inside the input field (onfocus) I want to change the text color to red. Then, when the person click outside of the input fied (no longer focus), I want to change the text color back to black. I know how to handle the JavaScript onfo...

WPF ListView Focus ListViewItem

I have a Model-View-ViewModel implemented for a searchable ListBox. My Xaml looks like this: (Please ignore the fact what I'm doing inside, it's just for test purposes) <ListView ItemsSource="{Binding Path=People}" > <ListView.ItemTemplate> <DataTemplate> <Border> <...

How to remove focus from a textbox in C#/WinForms

I need to remove the focus from several textboxes; I tried using: textBox.Focused = false; but the property is read only. I then tried setting the focus on the form, so as to remove it from all the textboxes, but this also fails to work: this.Focus(); and the function returns false when a textbox is selected. So; how do I remove fo...

Winform keyboard management

I would like to control the focus of my winform application. It is made of a custom listbox and several other component. I want all the keyboard event be managed by my window handlers in order to avoid specific control key handling (for example when I press a character and the list box is focused, the item starting with the correspondant...

Initiating editing on a PropertyGrid.

I'm looking for a good way to programmatically initiate editing on a System.Windows.Forms.PropertyGrid. I can select the GridItem that I want, but that doesn't move the cursor into the edit field. ...

Is it possible to avoid Focus on SplitContainer?

The WinForm SplitContainer gets the focus when it's dragged or clicked, while the Splitter does not. The side-effect of this, is that dragging a SplitContainer bar fires Leave/Validate on other controls, and I need to avoid this. I already tried setting TabStop and CausesValidation to False, but with no success. Is there a way to stop...

How to repeat a mouse click in .NET

My app runs as a plugin inside another windowed app. Thus, my window often doesn't have the focus. Now, if someone moves the mouse over a button/menu and clicks once, all it does is set focus to my window. Then (s)he needs to click again to get the actual button functionality. This is a minor annoyance but I'd like to get rid of it. Fir...

Exception changing focus with the tab key in a .NET application

I have a very simple Windows application, with a few controls, a DataGridView and the Adobe PDF viewer control. The app works fine except when tabbing around to switch focus between controls, I regularly get the following exception. System.AccessViolationException was unhandled Message="Attempted to read or write protected memory. Thi...

Disabling focus() from being run in an iframe?

I've got a page that has an iframe and web page in the iframe runs a focus() on one an input box in the iframe... how can I prevent that focus() from running? ...

WPF ErrorTemplate visible when not focused?

Hi. I'm using a WPF validation for TextBox validation. I have defined this Template: <Style x:Key="textBoxInError" TargetType="{x:Type TextBox}" BasedOn="{StaticResource StyleTextBox}"> <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter Property="ToolTip" ...

Setting the focus for Windows Forms element on WPF

Hi I am fighting for two days with this problem, and I am dying for a solution I have huge complex WPF window, with a tabControl One of the tabItem, hosts a WindowsFormsHost, which host some old windows forms controls When I am navigating to this tab, I am trying to set the focus on one of those controls Keyboard.Focus doesn't work, b...

Show helper text on clicking textbox using jquery

I want to display helper text on clicking on the text boxes. eg: If I click a text box it should help us by saying what to type: Enter username here I have tried below given code but the text "Enter username" is fading out, I want the text to be displayed until the focus is changed to another text box. please, suggest some code for thi...

Setting focus using left and right arrows (HTML + JS)

Is there any to make the left arrow behave like the tab button (set focus to the next focusable item) and the right arrow behave like a shift+tab (set focus to the previous focusable item)? I've gotten this far: $().keypress(function(e) { if (e.keyCode == 37) { alert('I want to do a shift-tab'); } else if (e.keyCode...

WPF TextBox.Focus() annoyance

Hi. I'm very new to .Net and WPF and have a problem. The code is a snippet. I have those TextBoxes to enter dates. I check on correct input using GotFocus and LostFocus events. <TextBox Name="sdDay" Width="40" Text="Day" GotFocus="DateDay_GotFocus" LostFocus="DateDay_LostFocus" Padding="5,5,5,5" HorizontalContentAlignment="Center" Focus...

TabControl and set the focus on a textbox in WPF

I have a tabcontrol in WPF When I switch to a specific tabItem , I want to set the focus on a specific textBox I added the code of textBox_n.Focus(); in the event handler of selectionChanged, but it didn't work. I added the code in the event handler of the tabItem's GotFocus, but funny enough calling textBox_n.Focus(), was calling the ...

ModalPopUpExtender shown from server-side: Controlling focus.

I have a user control that contains a gridview and a ModalPopupExtender (MPE). I'm using the MPE to force user decisions after certain ItemCommands from the gridview using the server-side Show() method. Showing the popup and getting postbacks or client-side scripts to execute from the popup both work beautifully. The issue at hand is t...

Managing input focus on an MFC SDI multiple view application

Hi all, We have a relatively large MFC application that uses an SDI to host a number of dynamically created CView- based views. The basic structure of the application is somewhat like Outlook (tree view on the left, dynamic view(s) on the right). I've been puzzling over the correct way to handle focus changing in the app. For example...

What Html markup for a focusable TD ?

I want to practive, and even best-practice, with Html+JS+CSS. I use a one page client-only Sudoku page. My Sudoku markup is basically a <table>, with <td>. (I'm open to suggestions to improve this). My requirements : Have a cell under focus (the keyboard notion of focus) (highlighed with css to a yellow background) Navigate through ce...