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:
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.
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?
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".
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.
A form's key events will fire when you press a key. Place a control on that form and it won't happen any more because that control has focus. There are exceptions to this however as you will see if you place just a h or v scrollbar on the form. The key event will fire because the scrollbars can't receive focus as is demonstrated by the following
Private Sub ScrollBar1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles VScrollBar1.GotFocus Debug.Print("Scroll GF") End Sub
So I've made my own special scrollbar usercontrol and i can't figure out how to have it leave the key events alone. I'm pretty sure that the problem is that my usercontrol can receive focus at the moment.
I found that the way of doing this is "SetStyle(Windows.Forms.ControlStyles.Selectable, False)". I put that in the new event of my usercontrol and now it looks like this:
Public Sub New() ' This call is required by the designer. InitializeComponent()
DataGridView TIPs has TextBoxes and ComboBoxes in it and the data comes from an SQL table. I see how to get or set the cell values that come from the ComboBoxes using Item, but how do I access the actual ComboBox events and properties?
I have an application similar to calculator, with button from 0 to 9, Enter and Clear. I made it possible to use the buttons by clicking on them and also by using numpad, like shown below: Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
I want to make an auto log off feature, I want to detect if there is any user input, and if there isn't the user will be automatically logged off. So I want to know how to detect mouse wheel events when the form doesn't have focus.
I have googled high and low to find an answer to this but I must be searching wrong.I have an application which has a listview displaying some items that are stored in a SQL Compact database. I am using a second form to add new items to this list directly into the database.When the second form closes I want to call the sub in my first form to refresh the list from the database.
How can I get it to fire the form1 sub routine on the close event of form2
I'm trying to set the focus to a ComboBox on program startup.[code]...
The DropDownStyle is set to DropDown so the user can type text in the text field. At program start I want the this control to have focus with the cursor in it & ready to accept text. As it is now the user has to first click on the ComboBox to type in it. Setting its focus doesn't seem to do what I want.
I have tried this code select and set the focus to the combo Box but it doesnt work... Private Sub DataGridView1_CellBeginEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles dgvProduct.CellBeginEdit ComboBox1.Visible = True ComboBox1.Select() ComboBox1.Focus() ComboBox1.Text = DataGridView1.Item(0, DataGridView1.CurrentRow.Index).Value End Sub
I have a datagridview with a combobox column. The combobox column is populated from a collection. I begin to add data to the dgv, I select in the first row a value in the combobox and go to the second row. In the second row, when the combobox gets the focus, it appears 'V18', also the selected value before. Why? An on the other, when the combobox in the second row losts the focus, the combobox value is nothing. Why? Here are two images:
When we click on drop down combobox control in our windows form, it shows the list automatically. But when we press tab and navigate to that control from keyboard it doesn't shows the list automatically. So in other to show the list automatically on receiving focus what should be done?
I have a combobox on an Excel worksheet that I can tab into, then pick my data (located on another worksheet) after activating the "arrow". But the tab or enter key does not allow me to navigate away from the cell after it is populated. The only action that allows the user to move to another cell is by mouse/click to another cell. I am trying to make navigation through though worksheet as user friendly as possible.I can't seem to find any sample code that will take the focus away from that cell using Tab or Enter.
I have no problem with ListBoxes created using the Data Validation method but I have to create a ComboBox control on the active worksheet in order to return the data chosen (in this case a code that corresponds to a description). If this was a Form I wouldn't have any problem as the properties would allow me to set that up, but this is essentially a spreadsheet I've inherited and the current users do not want to go to a Data Entry Form.
i need my application to determine if the desktop of the pc is locked or open.how would i go about doing this? i know that it is something to do with the registry but i dont know how to go about getting the values
In the context of data-bound combobox whose ValueMember and DisplayMember properties are appropriately set:Is there a difference between the SelectedIndexChanged and the SelecetedValueChanged events? Are they fired simultaneously when an item is selected from the drop-down list of the combo?
I added the colLocation to dgv."descirption" contains Unicode characters. I can see the comboBox correctly and choose the item.The problem is when the comboBox lost the focus, the value is changed to first item of the comboBox.
Updated:I found out that the ComboBox doesn't change the data when the DisplayMember is in English characters. It changes only when the DisplayMember is in Unicode chracter.
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?
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).
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.
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?
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?
I am bringing back here the subject of the communication between forms. The reason for this is that in a recent discussion in this forum it was conclude that using the events for communication between forms was a good practice. In a first time, I want to say, and everybody should agree with this that no form should never access directly any value or control values that belong to another form. There are many reasons for this but the principal one can be seen in this example
IN FORM1: TextBox1.Text="CrazyPennie" Dim MyNane as string = Textbox1.text With this code, Form1 will expect "MyName" to have the value "CrazyPennie".
But, if Form2 does access the directly the controls of Form1, it is possible for the value of MyName to be set to something else since Form2 can have changed the value of TextBox1.Text before the assignment by Form1 to MyName. Now, what is wrong about using the events for the communication? The problem is that an event is broadcasted throughout the entire application, so the conversations in between two forms are not private.
Look at this scenario: You have 3 forms in an application that communicate with each other with events. It is then possible for Form3 to listen to a communication between Form1 and Form2. It is also possible for Form3 to make the error to believe that the message send by Form1 to Form2 was address to itself. In this case, Form3, following this message may take some action that should not have been done and that result in some undesirable repercussion throughout the application.
This code keep the communication in between 2 forms private so no other forms or class in the application can listen at it and accidentally take an undesirable action due to a mistake. Option Strict On Public Class Form1 Delegate Sub MessageDelegate(ByVal sender As Object, ByVal Message As String) Dim Form2 As New Frm2 Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load [Code] .....
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()
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.
I have a form set up that allows the user to do many things to manipulate items. One of the things they can do is replace an item with another. To do so, what I have them do is click the Replace button on the main form. This calls the show of a choose replacement form where there is a grid view containing the replacement options and a Replace and Cancel button. When the user selects a product from the grid, and clicks the replace button, I want the item's ID to be sent back to the main form to be used in the replacement sub.This is what I have:
I have a tabbed webbrowser I want to add an event to it to make it so IE doesn't pop up when I click a link, with a normal webrowser that is easy but I guess I have to do a handler with the tabs being part of the browser and all. I have little experience with handlers. [Code]
I declared a browser in my VB.NET project (Dim browse as new WebBrowser). How am I supposed to get to the events (browse_NewWindow) of the declared thing?Oh yeah, my code for my browser is CType(TabControl1.SelectedTab.WebBrowser(1))
How can i code my application so that it can handle two sets of key events at the same time? For example, if I was making a game where one player used the WASD, and the other the arrow keys for moving, how can i make it so that both can move at the same time? The code I used only allows one to move at a time.. (key press event, If e.KeyData = Windows.Forms.Keys.down then.... etc)
I have a form with 2 contols that I with to connect by drawing a "wire" on the screen. It goes like this: you mouse down on the first control then move the mouse while holding the mouse button down. When the mouse is over the 2nd control the mouse button is released and the controls are wired.
So I am playing with mouseup, down, move, etc. When the mouse is over the first control I get mouse moves from that control, but when it moves off the events stop, and I get no events from the form even though the mouse is there.
Is there a way to do this? I have seen it done in a Java app. I could brute force it and just draw a box on the form instead of a control, but that sounds like a step back.