Forms :: Add A Sub To Run Whenever One Of Then Gets Focus?

Jul 19, 2010

I have a form with ~70 textboxes, and I would like to add a sub to run whenever one of then gets focus. I have:

[Code]...

View 2 Replies


ADVERTISEMENT

Forms :: Changing The Backcolor Of A Control When It Has Focus And Lost Focus?

Feb 16, 2011

Is there a more efficient/easier way changing the backcolor of a control when it has focus and lost focus? Let's say I've got 10 text boxes. Right now I would have 20 different events...10 for Enter event and 10 for Leave event. Of course, entering would change the back color to "green" and leaving would change it back to "white".

[Code]....

View 4 Replies

Forms :: Form Losing Focus - Keeps Loosing Focus ?

Nov 26, 2009

I have two forms in an application. One is he background and then I show another keypad form called with the show() method (not showDialog) because I need to perform some validations on btn click.

The kepad has 10 buttons and an Enter Button. The problem is that the form keeps loosing focus (I checked this with a messagebox which keeps poping up once for focus=true and again for focus=false, it continuously keeps losing and gaining focus) so it does not process any keypress events untill i click somewhere on the form. I tried using me.focus() in form load event but to no avail. The forms TopMost property is also set to true.

View 5 Replies

Can't Set Focus On A Windows Forms Textbox?

Jun 9, 2011

I can't seem to get input focus on a textbox when a tab page first comes up (I'm using Windows Forms, VB.NET 3.5). I have a textbox on a panel on a tab page, and I want the focus to be on the textbox when the tab page comes up. I want the user to be able to start typing immediately in the focused textbox without having to click on the textbox. I have tab stops set in the order I want and the textbox is the first tab stop. The tab stops work except that when the tab page comes up the focus is not on the textbox, i.e. the one that's first in the tab order.

In the Enter event handler of the tab page I call the Focus method of the text box, but it returns False and does nothing, no error messages. I know I can access the text box because at the same point in the code I can set the text of the text box.If it matters, the layout of the tab page is a little complicated:[URL]..I want to set the focus on TextBox1.

What's the best way to get the focus on the desired textbox? If setting focus is the best way, why is the textbox.Focus() method failing?

View 5 Replies

Forms :: Difference Between .Focus And .Select?

Jul 3, 2009

In VB6, Something.SetFocus sets the focus to that Something. No problems there - in .Net it's called .Focus.On another thread I was told (twice!) to use Something.Select in a particular scenario (which works fine by the way).

View 4 Replies

Forms :: Focus On The Very Last Word In The TextBox?

Jun 9, 2009

I make the TextBox1 properties become multiline and has vertical scroll. This is my code :

[Code]...

I made this code accidently. And it works. But I wonder, Is there a better to do it?

View 2 Replies

Forms :: Form Has Focus Over Others With Project?

Feb 4, 2009

is it possible to have the same effect as a dialogue box, with form focus? eg, when using the open dialogue box, if you try to focus on another form within the app, it doesn't' let you and starts flashing. But when you switch to another app, it doesn't interfere.

View 2 Replies

Forms Within Form Got/change Focus?

Jan 23, 2011

I have 1 form with about 5 other forms added into it. How can I check which form the user is currently on. I have tried using gotfocus for the 5 forms within, but it doesn't work. is there another way of seeing when focus has changed within the form?

View 3 Replies

Forms :: Unable To Set Cursor Focus In Sub Window?

Dec 20, 2009

currently I have a Customer Master screen. Inside the screen, I have a button which call the Customer sub window.

When I call the sub window, I want the set the cursor at Textbox1.

The problem is, when I call the window for 1st time, the cursor stops at Textbox1. When I call the window for 2nd or 3rd time, the cursor stops at other textbox or buttons inside the sub window.

Seems like Textbox1.focus is not working.

'***************Calling sub window from main screen**********
Private Sub BTN_CUSTOMER_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTN_SEARCH.Click

[Code]....

View 1 Replies

Forms :: Use The Focus Events Of The Combobox's To Determine?

Jan 7, 2010

I have two questions for anyone who can throw some idea's my way question 1:I am currently working on a control with three combo box's. This control will be nested on a form, and I want the on-board timer to track how long each control is active. I am trying to use the focus events of the combobox's to determine if the control is active so the program will know when the timer should be started and stopped. My problem is, for example, when the user causes the text property of the combo boxes to change, the folowing code runs:

[Code]...

As you can see, there are points in this sub-routine that can cause the focus to shift, as well as fire the text changed event. While this all happens faster than is really noticable, I would like to eliminate the extra cycles if at all possible. As I mentioned in question one, I am adding this control to a form, to be more clear I am adding multiple instances of this control to a single form, and I am trying to use the focus events to determine which of the controls within the form are active; however, when the form itself is no longer the active application, whether it is minimized, behind another application or otherwise, all of the timers stop. I want whichever control was active at the time that the form was deactivated, to continue as if nothing changed.

View 2 Replies

VS 2008 - Working With Two Forms (Focus On Both) At Same Time

Jan 18, 2011

I have a form from which I am visually representing data (from access database). I have set up a user log on a separate form (allows user to make comments as they scroll through the data and see any points of interest etc). The second form is linked via a textbox in terms of a common field in this case the field name is "Datetime".

What I want to do is be able to scroll through the data and make notes on the second form and add them to another table in the database. I have managed to do all the above but obviously loose focus of the second form when i scroll through the data on the first. Is there any way of being able to interact with both forms at the same time?

View 6 Replies

C# - Set Focus To A Deeply Nested Control In Windows Forms?

Jul 19, 2011

I have a main form that contains a vertical SplitContainer.Inside the SplitContainer's left panel, I have a TreeView control.Inside the SplitContainer's right panel, I have another SplitContainer (this one horizontal). This container is fixed, with headings above the split and a Panel control below it.I dynamically load my own user controls into the Panel control whenever the tree view changes.

Most of the user controls that are dynamically loaded have a DataGridView that should receive focus when the control is initialized. Sometimes this grid is on the UserControl surface directly; sometimes it's in a GroupBox; etc.What is the best way to programmatically set focus on the DataGridView control, given that it may placed within a variable number of control containers? I've tried the obvious - .Select, .Focus, .ActiveControl, etc. None of these seem to work - the TreeView item that I selected is still highlighted, and even though a record is selected in the DataGridView, it doesn't have focus.

Here's the code where I add the user control within the main form:

Private Sub LoadRightPanel(ByVal section As String, ByVal moduleName As String)
Heading.Text = String.Empty
SuspendLayout()
RightPanel.Controls.Clear()

[code]....

View 1 Replies

Forms :: Focus() Method Fails With Second Show Form?

Feb 7, 2010

I have a simple login field, which works fine with the exception of one quirk. The form is set up with the tab order to go to the UserID first and the Password text box second. This works fine when the form is used the first time, but when the form is used the second time the focus in placed in the Password field. If the form is used a third time, focus is moved the OK button, that is each time moves to the next tab order. I even tried to set the focus in the Load event as in Me.txtUserID.Focus(), but this doesn't change the behavior. Again, I should note that I close the form and not hide the form.

View 3 Replies

Forms :: Base Window Events Are Triggered When Focus Is On Another Form On Its Top?

Apr 3, 2009

I am migrating my code from vb.net 1.1 framework to vb.net 3.5In my windows application, the base window has some buttons and events are written for the same.I have shortcuts defined for these buttons also, for example: ctrl+d, DEL (keyboard) etc.Now i open a property Grid form on top of my base window for a selected object.Even when the focus is on this property grid, i am noticing that my base window events are firing on pressing those shortcuts.

example:I select some text in my property grid and hit delete button from keyboard. The delete event that i have written for the selected object gets fired and the text is not deleting.I fail to understand why is it happening. It wasnt behaving like this in .net 1.1.In .net 1.1 it would delete the text and only when the focus is back on the base window, hitting Delete would call the event.How do i control such a behavior? Is there some property that i need to set for property grid in .net 3.5 to prevent base window events from firing till the time focus is on property grid form?

View 1 Replies

Forms :: Restore A Windows Form Which Is Minimized And Has Lost Focus?

Dec 2, 2009

I have created an app which has a timer control which, when activated and meets a certain criteria, launches a second form with an alert for the user to review and action. this works just fine. Except.... when the main app is minimised and has lost focus, instead of launching the second form to a normal windows state it opens and sits in a minimized state itself and just flashes. How can I get the the second form to restore to a normal windows state?I have tried form2.focus and tried the windowsstate=normal etc but I'm still barking up the wrong tree.

View 2 Replies

Windows Forms: Unable To Click To Focus A MaskedTextBox In A Non TopLevel Form

May 20, 2010

I've got a Child form being shown with it's TopLevel property set to False and I am unable to click a MaskedTextBox control that it contains (in order to bring focus to it). I can bring focus to it by using TAB on the keyboard though.

The child form contains other regular TextBox controls and these I can click to focus with no problems, although they also exhibit some odd behavior: for example if I've got a value in the Textbox and I try to drag-click from the end of the string to the beginning, nothing happens. In fact I can't use my mouse to move the cursor inside the TextBox's text at all (although they keyboard arrow keys work).I'm not too worried about the odd TextBox behavior, but why can't I activate my MaskedTextBox by clicking on it?

Below is the code that shows the form:

Dim newReportForm As New Form
Dim formName As String
Dim FullTypeName As String
Dim FormInstanceType As Type

[code].....

View 3 Replies

Window Focus - Right Click On The NotifyIcon, Excel Gains Focus?

Mar 10, 2009

Here is what I've done:1) Created an Excel COM add-in for Excel 20032) Added a NotifyIcon to the Windows taskbar notification area (aka system tray) during ThisAddIn_Startup3) Added a ContextMenuStrip with a ToolStripButton to the NotifyIconWhy is it when I right click on the NotifyIcon, Excel gains focus? If after clicking on the NotifyIcon to display the ContextMenuStrip I choose not select an option on the ContextMenuStrip and instead click back on the Excel window, I get a weird flashing cell in Excel.I've created a video of the problem to help you see what I [url] anyone know how to prevent this? Ideally, I'd like to be able to click back on Excel and only have the ContextMenuStrip close and Excel regain focus.

View 1 Replies

C# - Books With A Focus On .NET Framework And Not So Much With A Focus On The Language Used?

Jul 18, 2010

recommend a book that focuses on the .NET framework in general and isn't too language specific.

View 3 Replies

Lost Focus Event, What Control Is Getting Focus?

Mar 21, 2012

I have a textbox on a form that when it loses focus it updates other text boxes on the form. But before it updates the other textboxes I check the input value in the textbox lostfocus event if it is undesired I return focus to the the textbox and alert the the user with a msgbox. However where my problem is, is that when the cancel button is clicked I don't care what the input in the textbox is because the changes are being canceled but if the value is undesired the it keeps returning focus to the textbox instead of canceling the changes. Is there a way to see what control was clicked on before or in the lost focus event? Can't seem to figure it out tried enter and leave events but no luck!

So for example something like this...

Code:
Private Sub TextBox1_LostFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus
If Control that was clicked <> btnCancel then

[Code].....

View 2 Replies

Me.Focus - Return Focus To The Form

Oct 25, 2011

After I did a sendkeys to another program from my form, i wanted to return focus to the form. i tried me.focus = true but that doesn't work.

View 1 Replies

VS 2008 Set Focus (new Currrent Cell) Setting Focus On Specific Cell In My Datagridview1

Nov 7, 2009

I am having problem setting focus on specific cell in my Datagridview1 . On Form1 when clicking on cell 3 in any row, I am callig a Dialog1. However, when done working with it, and closing the Dialog1, the focus returns to cell 3 in my Datagridview1 . I like to set the focus on the next cell(4) making it the current cell.

I have tryed :

DataGridView1.SelectionMode = DataGridViewSelectionMode.CellSelect
DataGridView1.CurrentCell = DataGridView1.Item(4, e.RowIndex)

DataGridView1.CurrentCell = DataGridView1.CurrentRow.Cells(4)

And few other things, I am always getting this exception: Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function.

View 2 Replies

Forms :: "Counter" On Form Quits Counting When Form Loses Focus?

Mar 15, 2009

Most of my experience in Visual Basic programming is in VBA. I'm currently trying to build a VB.NET Windows application that basically consists of a form that has one button and one label. When the button is clicked, the label should serve as a "counter" that counts from 0 to infinity until the user closes the window with the "x" button. I do this by putting a loop with a sleep statement in the onclick sub. The loop iterates the integer that is displayed in the label and does a "Me.Refresh".The problem is when the window loses focus. When it loses focus (when I click off of it), the counter stops. Even when I click back on it, the counter doesn't resume.

View 19 Replies

Set Focus On The Keydown Event So After The Button Control, Sets The Focus Into The Keydown?

Dec 15, 2010

Is it possible to set focus on the keydown event so after the button control, sets the focus into the keydown? although says often control can have focus,.Putting a button and a keydown event on a form...

View 2 Replies

Way To Get Focus

Aug 25, 2011

I am making a keyboard for my program in visual basic. This program is using touchscreen. Here is the idea, when i click the keyboard keys (button serves as my keyboard key) it will display the corresponding letters on a textbox that is on focus. How can I populate those textboxes if they are on focus?

View 2 Replies

Set Focus To Editing Row

Dec 14, 2009

How do you set focus to a specific control in a datagridview row after clicking the edit button? I'm able to do it for a new row when the grid is binding, but not for an existing row. The control doesn't seem to exist yet.[code]

View 1 Replies

.net - Focus On KeyDown In .NET?

Jan 29, 2012

Basically, for my first VB project, I am creating a virtual keyboard where a sound is played from the resources on KeyDown. So far, the program seems to work except for the fact that each key needs to be clicked by the mouse before the sound is played by pressing each key (hence put the object in focus), where I need the key to play the sound without clicking the keyboard key (put the object in focus on KeyDown). Below is an example of my code:

Private Sub C_KeyDown(ByVal sender As System.Object, ByVal e As PreviewKeyDownEventArgs) Handles C.PreviewKeyDown ' C is the label attached to the first 'Rectangle' (Key)
If (e.KeyCode = Keys.A) Then 'The A key should activate the C key on the keyboard

[code]....

I have KeyPreview set to 'True' under the form's properties.

View 1 Replies

Fix Highlighting When Getting Focus?

Mar 15, 2012

When I enter a vb.net textbox, if there is data in it, I want it to be highlighted. I looked around and couldn't find a property that would do this so I do the following:I built a little subroutine that does the highlighting and then call it from the ENTER and CLICK event on each text box.

[Code]...

View 2 Replies

Focus A Particular Row In Devexpress?

Dec 17, 2009

how to focus a particular Row in devexpress

View 4 Replies

Focus In Another App While Register In Another

Oct 2, 2011

it is an on screen keyboard. you press the button with your mouse and it will type in another app you place focus on the bit i am trying to figure is how do i make a windows app using vb that when i do something in it it will register in another app? in other words how do i get the actions in one app to register in another open app?

View 1 Replies

Focus On A Certain Region?

Jul 4, 2009

How can I make it so that if the cursor position is anywhere from 200 to 500, it'll make "Region" = true?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved