MsgBox("ERROR: Unable to start selected form. MsgBox("The selected option is not available.", MsgBoxStyle.OkOnly, "Menu Selection") ' Form to run not specified so inform user not available. ' Exitoption is false and optionExecute has a form name so try andĪctiveForm1 = CType(Activator.CreateInstance((frm1)), Form) Keyup enter code#' ActiveForm1 is still available to read any values needed so put code here. 'close this menu form and return to passed formĭim ActiveForm1 As Form = CType(Activator.CreateInstance((frm1)), Form) ' and the user wants to return to that menu form to select a different option. ' OptionExecute is not empty so it should have the name of previous form or menu ' If OptionExecute is empty assume we are at the top level menu and the user wants ' to the previous menu or exiting the application. ' ExitOption is true so check OptionExecute to see if we are returning Private Sub TextBoxNoMouse_KeyPress(ByVal sender As Object, _īyVal e As ) Handles Me.KeyPress It has custom properties to determine if it is and exit button that closes the menu, what form to run when enter is pressed and to manage arrow key navigation. The textbox is a class that I drop onto the menu form as needed. but I find it hard to beleive that one, the key stroke gets passed to the called form and two, that there does not seem to be a way to prevent it (not that one should have too, I know I can deal with this in the called form with a flag, etc. As a result the focus on the form being run moves from the first control on the form where is should be to the second control in the tab if you use Tab exclusively for navigation this presents no problem as the enter key is just consumed and nothing happensīut the forms I have to create allow navigation by the enter key or tab, IOW, Enter moves to the next field on the form. When the user presses enter on the menu form that key stroke gets passed through to the form being run when ShowDialog executes. The menu form creates an instance of the form to run, make itself invisible and executes a ShowDialog on the newly created form.The textbox keypress event handles running the selected form when the enter key is pressed. The basic process is: Yes the tab order is set correctly so Tab move the focus but navigation is also controlled by the textbox keydown event to allow arrow key navigation. Private Sub frmItem1_FormClosed(ByVal sender As Object, ByVal e As ) Handles Me.FormClosed If NextTB Is Nothing Then NextTB = TextBox1 Handles TextBox1.KeyPress, TextBox2.KeyPressĭim NextTB As Control = GetNextControl(CType(sender, Control), True) Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As ) _ Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As ) Handles tbMenu1.KeyPress Since you did not show your code for the KeyPress event handler it is difficult to to offer much guidance other than to show some snippets of how I would code it based on your described behavior requirements. NET deficiencies.Īre your sure that you have the Tab Order set properly on your data entry form? With and would like to find a solution I can apply on the menu form rather then adding code to every data entry form to compensate for. I realize there are many ways to force this to work as I intend by putting flags and so on in the data entry form but I have many to deal In the keypress of the textbox on the menu form e.handled is set to True but that does not prevent the passthrough. Having the enter key move to the next field like tab does is also To be in the first field on the form but the first controls keyup event triggers and the enter keypress from the menu form is still active so the cursor moves to the second control on the form. When the data entry form opens the cursor is supposed When the user presses enter on the textbox on the menu form the keypress event is used to invoke the selected data entry form and the menu form is hidden. The problem I could use some help with is this. Not my idea but it is my job to make it so. The reason for this is a requirement that the mouse must not function at all in thisĪpplication. Pressing enter while the textbox has focus invokes another form and hides the menu form. I am working on an application using a form with textbox controls as a menu.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |