Losing Focus of Textbox in Silverlight - silverlight

I have a silver light page in which i am entering some value in a text box (this is not the first Text box in appearance) and clicking on the search button.
After getting the result from the database the focus is losing to and shifting to the first text box which is also a search criteria.

Have you tried anything?
You need to first re focus your Silverlight app, then set the focus to the text box that you want.
try:
this.Focus(); then Dispatcher.BeginInvoke(() => { mytextbox.Focus();});

Related

Winform - multi line Textbox changes scroll position on refresh

I have a winform application that has a textbox, multiline, readonly where I display a kind of log that is refreshed each second. The text box can have more than 100 lines of text.
On each refresh, if the user scroll and selection are lost.
I need a way to allow to the user to keep the scroll and selected text.
I tried to replace only the line that changes - didn't work (using Lines property)
I tried to save the selection before update and re-select it after - didn't work.
I tried to use RichTextBox instead - didn't work.
Anyone did something like this before? Is any library (custom control) I can use instead?
Thank you.

How to set focus on textbox and button simultaneously in WinForm

I want to set focus on a button while caret is present in textbox and user can still enter data to textbox. But when user presses enter key, button press will be simulated.
I am currently using a work around to solve this problem by handling onKeyDown event and checking for enter key. But problem is there is no clue for user to understand this as there is not blue border around the button that indicates focus on button.
Here is a example of what I want to implement (user can enter text in textbox while focus is on :
I have tried to search on google and StackOverflow but could not find any relevant result.
This is a fundamental Windows principle. It's not possible to have 2 controls (windows) focused at the same time.
So the focus should be inside the text box. But you can get the visual indication needed by setting the ok button as AcceptButton of the form (you might also want to set cancel button as CancelButton).
In the form constructor, load event or using designer:
this.AcceptButton = okButton;
There is no need to handle KeyDown event - as soon as the text box is not multiline, pressing Enter while the focus is inside it will generate ok button click. The same applies for the button set as CancelButton when you press ESC.

How do I select all the text in a WPF textbox on click

I have several TextBoxes within a UniformGrid.
I want to select all the within a textbox when it is clicked I'd rather the event came from the uniformgrid. I was able to implement selecting all the text with GotKeyboardFocus for when I use only the keyboard with the code below in the handler. However when I merely click on the box it highlights while my mouse is down and on mouse up the cursor appears rather than the text remaining selected.
foreach(TextBox Box in grid.Children)
{
if (Box.IsKeyboardFocusWithin)
{
Box.SelectAll();
e.Handled = true;
break;
}
}
I also have an PreviewKeyUp handler that watches for a max number of letters then moves to the next box. Also each box is initialized with the max number of letters when the screen loads. Which is why I want to do a select all on the text in the textbox so it can be typed over easily.
I was able to use GotMouseCapture almost perfectly except that it doesn't work if you click near the text only near the edge of the textbox.
Try hooking up to the PreviewMouseUp routed event. That worked for me.

How to keep focus in MessageBox

I am using EditorGridPanel with cellEditor which acts nearly like Excel. We implemented Arrow Keys to move among rows and columns.While validating a row, if it does not match the validation rule we show a MessageBox and hope that focus does not move if it is not valid. But, after the MessageBox shows - focus moves to the next row/column. Another problem is, user have to click in the OK button of the MessageBox to remove that from screen. Can we have the focus on the invalid column editor and also focus on the MessageBox OK button - so that user can press Enter to hide the message and continue entry?
Please check our link. http://www.softworksbd.com/swazilandlmis/yyyy_stockdata.php
Only one element can be focused, so focus should go to the message box. AFAIK enter/escape keys works out of box with message box.
You can pass callback to the messagebox. In this callback you can focus desired cell in the grid. Like this:
Ext.Msg.alert('Title', 'Message.', function(){
this.startEditing(rowIndex, colIndex);
}.createDelegate(grid));
So after message box is closed, the focus will go back to the editor.

ms-access: is it possible to change a combo box to text box using vba?

is it possible to change a combo box to text box using vba?
As an addition to the suggestion about hiding the text box I have seen people use a text box to cover all but the dropdown arrow of the combo box (text box set to be on top of course) and then updated the text box on the after update event of the combo box
I forget why they did it that way in the end but it worked and IMHO is better than hiding the combo box as you might have issues with it still having focus
As far as I know there are two methods. If the form is in design mode then running;
Application.RunCommand acCmdChangeToTextBox
while the combobox is in focus will make it turn into a textbox.
However you cannot do this at runtime. Say you want to show a textbox after selecting a value from the combobox, on the Change event of the combobox you just hide it and show a textbox that was previously hidden. Use the visible property of the combobox and the textbox for this.

Resources