.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Losing Focus..

Posted By:      Posted Date: September 09, 2010    Points: 0   Category :Windows Application
I have the code and  it is below. I have eliminated the errors and  it debugs fine. But it is not doing what I want it to. In fact it's doing nothing. Just want the textbox1 to increment when it loses focus. I believe I have all the hooks etc... So the big concern is when the Alt key is held down and then the print screen key is released (the up) it should increment  the textbox1 if  the focus is lost.   So maybe  if there might be someone out there who might give me some pointers and head me in the right direction I can final call this finished. I appreciate it. Thank You.    public partial class Form2 : Form     { private KeyboardProcedure keyboardProcedure;    public Form2()         { InitializeComponent();   this.KeyUp += new KeyEventHandler(Form2_KeyUp);           }  public void Form2_KeyUp(object sender, KeyEventArgs e)         {                    //If the Alt key was pressed and the PrintScreen key was the one released, bump the counter and update the                                 //textbox.             if (e.Alt && (e.KeyCode ==

View Complete Post

More Related Resource Links

Calendar NOT losing focus WPF 4.0


I have a WPF 4.0 Calendar control (Selection Mode: MultipleRange) and a button in a grid.

After selecting dates in the calendar, when I click on the button, the calendar is not losing its focus.  i.e., It leads me to click twice on the button to fire the button_click event.

Is that a known bug? I binged my level best but not finding any answer. I will appreciate if someone could solve it.

Thank you.



lossing focus from model pop up window controls


hi i using a model pop up window with some textbox but when i click on textbox of model pop up focus move to back to page textbox control plz help me 

Transactions: Build Scalable Systems That Handle Failure Without Losing Data


Systems that handle failure without losing data are elusive. Learn how to achieve systems that are both scalable and robust.

Udi Dahan

MSDN Magazine July 2008

Excel-like experience - gridview focus problem



I'm creating a page where people can order several items from a list without having to press "edit" and "save" in between like you normally would in a gridview. The user writes down the quantity, and finally presses a "submit" button that saves the order.

I want the user to have a windows form (or excel) like eperience, so once the user puts in the quantity and moves on to the next item, either by TAB or by clicking on the TextBox, i make some calculations without the user beeing bothered with a full refresh or having to press a buton to execute the event, so I place the controls inside an UpdatePanel and use TextBox.TextChanged. The event runs code that calculates the sum for the row (price * quantity) and shows that in a column called "Sum", and updates a label in a fixed position with the new order total ("Total").

Any ideas on how to achieve this?

Right now I use a GridView with a templatefield for the Quantity and set the TextBox.TextChanged event to fire to make the calculations. The problem is that the focus then changes.

By using SmartNavigation or the ScriptManager.SetFocus I manage to retain focus on the TextBox that executed the Postback, but the user might have moved on to a textbox far down the gridview (thus causing the postback by leaving the previo

Generated controls - skipping focus event - C# + JS


Ok, here is my senario.

A random (6-15) amount of textboxes are generated. Each textbox represents only one character. From those textboxes, three of them (at a random position) are enabled and the rest disabled.


When I put a character in any enabled textbox, it must put the focus on the next enabled textbox.


Textbox IDs go from 'char0' to 'char15' OR 'char0' to 'char12' OR ...

All the textboxes are generated so I can't set up specific focus events for each textbox because the designated control is unknown at design time.

Here is my attempt:


<script type="text/javascript">
    function abc(nextfocus)


for (int i = 0; i < focusableControls.Length-1; i++)
focusableControls[i].ClientSideEvents.KeyDown = "abc(" + focusableControls[i + 1].ID + ")";


focusableControls is an array with all the textboxes in that can get focus. It is also in the right order.

Things I want to find out:

How will I send the textbox out of focus

Losing the value


Theres is a variable in my program but I always lose the value . I want to stay with this values to use . How i could do this ?

Partial Class pages_dossie_relatorio
    Inherits System.Web.UI.Page

    Dim tam As Integer = 10



Request.PathInfo losing Master Page content and CSS link


Hi All-


I'm using Request.PathInfo to response.redirect as user to a different page ( based on the content after .aspx ).  It redirect just fine however, once redirected, the page loses all content from the master page and the CSS link.  I've searched and can't find an answer. 

Does anyone have a solution for this?

Toast Popup Form is Stealing Focus

I have a Windows Form application that when it is running a process it displays a MSM type toast popup.  The problem is when we create this form in a second thread and display it.  The problem is when it is displayed it steals focus from other applications or even our own.  Anyone have any ideas on this and how to make it not steal focus. I create the popup in a thread pool. ThreadPool.QueueUserWorkItem( new WaitCallback( DisplayPopUp ), new PopUpParameters( BackgroundImage, ForeColor, Clicked, Delay, Message, ButtonText ) ); This is the code for DisplayPopUp: using (PopUp p = new PopUp((PopUpParameters)popUpParameters)) { p.ShowDialog(); } Inside the form it has 3 timers.  One for Pop, Pause, and UnPop.  The form Load event is where the position of form is set and the event pop timer is started.  The events for Pop and UnPop just change the form Top location.  The form is not set to TopMost. Any help would be great. Thanks, Eric

After a void the HTMLEditor gets the focus?

 I've got a aspx page with 2 update panels. The first has a HTMLEditor (ajax control toolkit), and the second had a textfield and a butten.after i push the button (of course there is some action but no focus things) afther the action is done the focus gets to the HTMLeditor.Why ? There is no page reload (because of the updatepanel) so why get the htmleditor the focus? And the importent thing, how can i solve this?

Move focus while mouse down?

Hi All I've a button with a adoner containing a scrollbar, when the user click and hold the button for 2 seconds the adoner becomes visible, this works like a charme, and the adoner become invisible when the user release the mouse button again. My problem is, I don't know how to move the mouse focus from my button to the scrollbar, to make it scroll while the mouse still is down. In other words how do I move over a scrollbar while the mouse button is down, and then the scrollbar gets the focus and begin to scroll to the mouse pos. Please help me. Spandy   

How to set the border for a WPF DataGrid Row which is currently having the focus

Hi, I want to set the border for a DataGrid Row which is currently having the focus. But not the seleced row because when the Multi selection is enabled for the datagrid then there is a chance that multiple rows can be selected. I need a solution in XAML Thanks in advance! Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This will help other members to find the solution easily.

Losing responses from the device- UdpClient

Hi all,    In my application i am using UdpClient class for communication between the PC and the device. There are 3 tabs, on click of each tab a WindowsFormsControlLibrary (a dll) is opened an on click of any button in these tabs a request to the device is sent via udp socket and the device sends the response for the corresponding request. On receiving any response from the device the respective slot is called by the use of events and delegates.  A thread is created to notify the respective slots in the different tabs  when some response is received. For every 1 second the device sends a response to indicate that the device is active. These responses are displayed in the datagridview in one of the tab. The problem is some responses are lost and because of which the order of responses is not correct. The code is as shown below: </> public void dataReceived()                                 {                                                 IPEndPoint remoteIp

Premature loss of focus in WPF user control

I have a user control that consists of a dockpanel, inside of which are a textbox, a stack panel (containing two user controls), and another user control.  I am handling the LostFocus event for the dockpanel.  Since LostFocus deals with Logical Focus in WPF parlance, one would logically (pun intended) assume that if one was to click anywhere inside the dockpanel, the LostFocus event should NOT be fired for that control.  However, it appears that If I click anywhere outside of the textbox in the dockpanel, the LostFocus event is fired.  I am not using custom focus scopes since there are multiple of these user controls in my WPF window and I only want one of them to have focus at any given time. I've read many blogs and articles on WPF focus issues and so far nothing has worked.  Any help would be highly appreciated.

How to prevent Javascript window to steal focus

Hi,I have made an asp.net web application in which i open a javascript window for 4 seconds at regular interval . The problem is that when window opens it steals focus from current application. For example when application is running in background or is minimized and i am typing in word/Excel or outlook, the window pops up and steals the input focus.I want to popup window in some way that it never steal focus from some other application, just like msn or gtalk notification when someone sign in/out.Please suggest how it can be done ? Thanks

MaskedEditExtender Gets Focus on Postback

I'm having a really strange issue with the MaskedEditExtnder. I've attached some markup for one of the textboxes. I'm using a MaskedEditExtender and MaskedEditValidator along with a CalendarExtender so the user has the option to type the date or click on an image and pick the date. So, if I enter/pick a date then select a control that forces a postback (usually a dropdownlist but not always) when the page is returned the focus goes back to the textbox I just entered the date in. So what about the MaskedEdit, MaskedEditValidator, CalendarExtender would cause the page to return focus to the control being extended? See markup below - am I missing something??  <asp:TextBox ID="txtEffectiveDate" runat="server" Width="100px" CssClass="textbox" AutoCompleteType="Disabled" Font-Bold="True"/> <asp:ImageButton ID="ImgBtnCalc1" runat="server" ImageUrl="~/images/Calendar_scheduleHS.png" CausesValidation="False"/> <cc1:MaskedEditExtender ID="txtEffectiveDate_MaskedEditExtender" runat="server" Enabled="True" TargetControlID="txtEffectiveDate" Mask="99/99/9999" MaskType=&qu

HTTPContext.Current.Session losing the variable sporatically

I have noticed a strange behaviour in my ASP.net 2.0 application. I have some logic in my aspx page that accesses some Session variables fine, then accesses some app_code and most of the time the HTTPContext.Current.Session returns the variable back fine.  However, I have noticed that sometimes this Session returns null, like it has lost it's "pointer" to the current HTTPContext. Is this a known bug, has anyone seen something like this before?   Any help would be appreciated, thanks, Mark. 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend