tailieunhanh - Mastering Microsoft Visual Basic 2010 phần 3

Con số này cho thấy đã có một mối quan hệ giữa các bảng Danh mục và bảng các sản phẩm. Kêu gọi các phương pháp CanUndo và CanRedo là không cần thiết, nếu không thể thực hiện các hành động tương ứng, hai mục trình đơn sẽ bị vô hiệu hóa, nhưng một kiểm tra bổ sung không có hại. | 178 chapter 5 BASIC WINDOWS CONTROLS LISTING KeyUp event examples Private Sub txtEditor_KeyUp ByVal sender As Object ByVal e As Handles Select Case Case Now .ToLongDateString Case Now .ToLongTimeString Case MicroWeb Designs Inc. Case Another user-supplied string End Select End Sub Windows already uses some of the function keys for example the F1 key for help and you shouldn t modify their original functions. With a little additional effort you can provide users with a dialog box that lets them assign their own strings to function keys. You ll probably have to take into consideration the status of the Shift Control and Alt properties of the event s e argument. To find out whether two of the modifier keys are pressed along with a key use the AND operator with the appropriate properties of the e argument. The following If clause detects the Ctrl and Alt keys If AND Then Both Alt and Control keys were down End If If you need to control the keystrokes from within your code a rather common scenario in an advanced functional user interface design you should be aware of the order of the events fired every time a key is pressed. First the KeyDown event is fired this event is fired before the keystroke is passed to the control. This is the event in which you should kill any keystrokes that you don t want to be processed normally by the control or replace them with a different key. Then the KeyPress event is fired if the keystroke corresponds to a character number or symbol but not a control key. Finally the KeyUp event is fired. By that time the keystroke has already been processed by the control and it s too late to kill or replace the original keystroke. Can you guess what will happen if you insert the following statements in a TextBox control s or Form s KeyDown event .

TỪ KHÓA LIÊN QUAN