In this video we will see how to make it easier and use by the user of our application written in Visual Basic 2010, inserting the shortcut that allow direct access to the functions of our controls, controls that are present on our forum instead using only the keyboard and mouse.
In the last video we had been in this situation is both our name and surname textboxes and a button that allows the processing of your name, address and generates a message that shows the name as surname. Now there remained only change the text displayed on the button to which we take the left mouse button select the Text property is added to the default Button1, select and edit to show results that is the function of this button. Since the text displayed in the button is too long for the standard size of the button, then move through these boxes we drag our control. Pressing the left mouse button while holding down drag until the text is displayed fully we now think of the contrast that is additional to add a keyboard shortcut to our control. allows for a shortcut to use the alt key combinations than any button to go directly to the keyboard functions that expose our control.
So for example, ALT TAB, could enable our button or the CTRL key instead of C there may activate another control on our Forms
To enable keyboard shortcuts in Visual Basic 2010 is necessary to include an & (ampersand) in the Text property of the letter and immediately subsequent to the letter & will be pressed in combination with the ALT key to activate the shortcut.
Generally we consider the most significant point of the text of a control such as in our case in the event of this button displays the result "the two letters that we might consider creating a sort that may be the M of" Show "or "R" of "Result".
Much also depends on the shortcut between the different keyboards that we already used for other controls. For example, if "N" is still free then we can use it safely. If another control were already using the letter "N" to create your own shortcut we will be forced to fall back on another letter. In this case being the first control that takes into consideration we can safely use the "M" so as I said before we add a & M in front of the "Show".
On the side and we see that the "M" in our present un'underscore button, an underscore. this means that our shortcut, just created it worked properly. In order to do a test but we have to add a notification that there behind the button shows results that it returns a notification that the button was loaded.
To which we add the code to the click event he will be something that we will see later that it is now important to focus not so much on the code to be written as evidence that the shortcut has produced a result we wanted.
Ok, this short line of code displays a message on the screen that gives us confirmation that the button was pressed. So we go back to save our project design and F5 or by using this button. As we can see the button does not see any 'undescore or underscore, does not see any shortcut for this you need to press the alt button and at the same time, if you press ALT M was triggered by the click of a button the keyboard so we have absolutely nothing and uploaded on the button with the mouse it shows the shortcut that has worked well.
If we can do the same work on other controls, nothing forbids us to add a shortcut to the label text label which assets directly in the text box that is referenced by this standard method of paper lands assign a control source that has a text property or whose text property is not suitable for these purposes to use a label to assign a shortcut to the control associated with it.
Ad'esempio the text box is necessary that the TabIndex property of the label has a value lower than the control was referring to. The TabIndex property is nothing but the index to sort the checks in the forum. five of this nebula as the index launched three million then this prophet will be the third control and how to sort this text box art has been assigned an index of properties between the control her surname bubble was marked by four booths this the two text box to say that all this pressing the Tavor to our forums you will move from one control to another without using the mouse in the order and we see just happened in the index to do a test by pressing TAB go to the first control is the control that it was an accurate index. This text box TabIndex property related to that other text box so that pressing the TAB key, we move on we see what the second text box control with TabIndex on Form 3. It should be this label and it is. So we return here by pressing the TAB key, we expect to pass on this label so it is not because the label, when it gets focus, it returns the control has a tabIndex value immediately following.
If the control with TabIndex later than the label on which we placed is also a label, then the control will continue until the control has the focus will not be a different control. So if you press the TAB key we find ourselves directly with the focus on the button shows the result shows no results occur at a TabIndex of six that is the last of the Form, this means that the TabIndex three and four were TabIndex skipped that to make sure that the text boxes can have their Shortcut we need to ensure that the label is lower than that of the text box is referring to. So this text box has its TabIndex 2 Label TabIndex has four. So we want the Label has a TabIndex that is the first.
Then assign the TabIndex to a text box and then have a TabIndex immediately following two. This Label will have a three and TabIndex this text box will also have a TabIndex immediately following the label name. Now assign the shortcut by putting a & in the Text property of the Label name and see that we are now highlighted in the character, that has been assigned the shortcut. We have the project ready to be started. Start them by pressing F5 on the toolbar of Visual Basic 2010. Try pressing the TAB key to move from text box to the Name text box without using your mouse. Here we did it by pressing the ALT M should still be able to press the button without a mouse. And by pressing the ALT N will allow us to return to the first text box. What happens for example if we want to use the Label Name the ampersand? That is, if we want the Text property of that name was the name & last name? It 'clear that the ampersand is interpreted as a symbol of shortcut. To avoid this behavior then I must go down to the UseMnemonic property and give it the value False. Here is the ampersand & is back and normal. " This will prevent us, however, to use the shortcuts as we did previously for which to return to the previous condition we reassign the value True to this property and in our case back to plain text name as the text property of label control.
Google Traduttore per miei elementi quali:RicercheVideoEmailTelefono