.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

Which control has focus?

Posted By:      Posted Date: October 22, 2010    Points: 0   Category :Windows Application


How do I tell which, if any, control has the focus on a form?

I'm writing a function key handler and want to determine context.

I see ContainsFocus but that doesn't appear too useful unless you check each and every control. And it may return a false positive in that it looks like it can return true for containers that have a control with the focus on them - I need to know the control with the focus.

I see some posts that say ContainsFocus can be used to check to see if a form has focus but Me.ContainsFocus doesn't exist. How does ContainsFocus work for forms?

View Complete Post

More Related Resource Links

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.

Set focus on erronous control on validation inside ajax tabcontrol having 5 tab


Hiii.. Everybody

How to set the focus on textbox when requiredfield validator error mesage comes to action inside the ajax tabcontrol.The ajax tabcontrol is having 5 tabs.The submit button is in 5th tab .I have reqiredfield validator for textbox  in 1st tab.I want to set the focus on textbox if validation fails.Is it possible to get without postback????

Is there anyone can help me out ????

Thanks in advance

How to set focus to UserName textbox in Login Control ?



can you please tell how to focus cursor to UserName TextBox in Login control when page is loaded for the first time in browser ? 

Missing control focus


Hi, i just have a problem, i dont know if it's caused for a postback event on the page or something else.  I just have added a functionality to a asp.net designed UserControl that preloads a control value depending of another control value.  I use the OnTextChange event of sender control and the AutoPostBack property at this is enabled.

Rigth now the control just do what i need, it preloads another one control value, the problem is that at this control (a textbox) have an autocomplete extender and when i change the value preloaded i can't continue filling my form before i just select a control like a dropdownlist and get back to continue editing my form.  Every textbox controls in my form looks like disabled, the problem is i certified the control is enabled by debugging my code.

Thanks for your help,

Bringing SelectedItem Into Focus Using DataGrid Control

When using datagrid control of the silverlight control there is situation when datagrid control has lots of records and vertical scrolling of the datagrid control is visible and the selected item of the datagrid control is not in the view as the scrolling (vertical scrolling of the datagrid is visible due to large record). So it is important to give focus to the selected item of the datagrid control.In this post I will give you solution of this problem which many of you may have face.

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

Accessing the different controls inside a GridView control

how we can access a particular control which resides inside a GridView control. In this article I will show you how you can access different controls inside a GridView control. We will see how we can access a TextBox control, a DropDownList control and a ListBox control. If you are working with ASP.NET 1.X then you might want to check out my article Accessing Different Controls Inside a DataGrid.

In-Depth look at the GridView Control

In the last article we looked at few of the new controls available in Asp.net 2.0. We also talked about Grid View Control which has replaced the Asp.net 1.1 DataGrid control for good. In this article we will examine more features of the Grid View control. In this article we will see some of the common operations that can be performed using the GridView control. Apart from these operations there are many more functions that can be performed on the control and which we will see in the later articles

ASP.NET repeater control - databind with style

even used the inline editing features, which I at the time thought was the coolest way possible to write ASP.NET code ( I managed to write code to hide all other rows and only show the current one - the row being edited). With a nice looking EditTemplate it looked indeed very slick but it really turned into giant and hard to manage code behind files.

Creating Paging for a Repeater Control

A common question is "How do I implement paging within a Repeater?" Although the beauty of the Repeater control is its flexibility, you're on your own for building most functions. ASP.NET 2.0 has included some new controls that provide paging, as does the DataGrid in ASP.NET 1.1. However, this tip shows you how to roll your own paging for a simple data viewer.

Using TemplateFields in the GridView Control

The GridView is composed of a set of fields that indicate what properties from the DataSource are to be included in the rendered output along with how the data will be displayed. The simplest field type is the BoundField, which displays a data value as text. Other field types display the data using alternate HTML elements. The CheckBoxField, for example, renders as a checkbox whose checked state depends on the value of a specified data field; the ImageField renders an image whose image source is based upon a specified data field. Hyperlinks and buttons whose state depends on an underlying data field value can be rendered using the HyperLinkField and ButtonField field types.

How To Add calendar control inside a GridView

This article show hot to add calendar control inside a GridView with code in c#

Using ATLAS PopUp Control with Calendar inside the GridView Control

In this video tutorial Mohammad demonstrates how you can access the Calendar control which is displayed using the ATLAS PopUp control inside the GridView control.

GridView control to show master-child or master-slave data, written in c#, asp.net

I previously made a master slave datagrid using Visual Studio 2003 .Net (original article) that would allow users to show data to clients using collapse and expand features. These features however did not carry over to gridview for many users. This tutorial will explaing how to create a collapsable/expandable gridview in frameworks 2.0 and higher

Easily manipulate data with the GridView control in ASP.NET 2.0

Last week, I introduced ASP.NET 2.0's GridView data control and covered the basics of using it. This week, I go a step further by going into the details of working with the data contained in the control. This includes viewing, editing, and deleting data. Thankfully, the GridView control makes it easy to utilize these features. Before diving into these topics, I begin with an examination of the different field types supported by the GridView control.

GridView Multiple Filter AJAX Control

This AJAX control enables the user to filter data within any column inside a GridView. The user can add multiple filters and can delete existing ones too.

Choosing Between a User Control or Web Part for SharePoint

SharePoint will only display Web Parts on a page. However, there are publicly available shims that allow you to write user controls and have them be displayed as a Web Part. From SharePoint's point of view, the shim is a Web Part. From the point of view of the user control, the shim is simply a control in .NET that is including the user control
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