青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

twzheng's cppblog

『站在風(fēng)口浪尖緊握住鼠標(biāo)旋轉(zhuǎn)!』 http://www.cnblogs.com/twzheng

  C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
  136 隨筆 :: 78 文章 :: 353 評(píng)論 :: 0 Trackbacks
.NET Framework 類庫  

Control.KeyPress 事件

在控件有焦點(diǎn)的情況下按下鍵時(shí)發(fā)生。


[Visual Basic]
Public Event KeyPress As KeyPressEventHandler
[C#]
public event KeyPressEventHandler KeyPress;
[C
++]
public: __event KeyPressEventHandler* KeyPress;

[JScript] 在 JScript 中,可以處理由某個(gè)類定義的事件,但不能定義自己的事件。

事件數(shù)據(jù)

事件處理程序接收一個(gè) KeyPressEventArgs 類型的參數(shù),它包含與此事件相關(guān)的數(shù)據(jù)。下列 KeyPressEventArgs 屬性提供特定于此事件的信息。

屬性 說明
Handled 獲取或設(shè)置一個(gè)值,該值指示是否處理過 KeyPress 事件。
KeyChar 獲取與按下的鍵對(duì)應(yīng)的字符。

備注

鍵事件按下列順序發(fā)生:

  1. KeyDown
  2. KeyPress
  3. KeyUp

非字符鍵不會(huì)引發(fā) KeyPress 事件;但非字符鍵卻可以引發(fā) KeyDownKeyUp 事件。

要僅在窗體級(jí)別處理鍵盤事件并且不允許其他控件接收鍵盤事件,請(qǐng)將窗體的 KeyPress 事件處理方法中的 KeyPressEventArgs.Handled 屬性設(shè)置為 true

有關(guān)處理事件的更多信息,請(qǐng)參見使用事件

.NET Framework 精簡版平臺(tái)說明:  除了 Control 基類外,.NET Compact Framework 還支持具有 Service Pack 2 及更高版本的控件上的該事件。Smart Devices Developer Community(智能設(shè)備開發(fā)人員團(tuán)體)Web 站點(diǎn)提供了有關(guān)可用 Service Pack 的信息,請(qǐng)參見 http://go.microsoft.com/fwlink/?LinkId=16561。

示例


[Visual Basic] 
' Boolean flag used to determine when a character other than a number is entered.
Private nonNumberEntered As Boolean = False
   
   
' Handle the KeyDown event to determine the type of character entered into the control.
Private Sub textBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) _
     
Handles textBox1.KeyDown
    
' Initialize the flag to false.
    nonNumberEntered = False
  
    
' Determine whether the keystroke is a number from the top of the keyboard.
    If e.KeyCode < Keys.D0 OrElse e.KeyCode > Keys.D9 Then
        
' Determine whether the keystroke is a number from the keypad.
        If e.KeyCode < Keys.NumPad0 OrElse e.KeyCode > Keys.NumPad9 Then
            
' Determine whether the keystroke is a backspace.
            If e.KeyCode <> Keys.Back Then
                
' A non-numerical keystroke was pressed. 
                ' Set the flag to true and evaluate in KeyPress event.
                nonNumberEntered = True
            
End If
        
End If
    
End If
End Sub
 'textBox1_KeyDown
   
   
' This event occurs after the KeyDown event and can be used 
'
 to prevent characters from entering the control.
Private Sub textBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) _
    
Handles textBox1.KeyPress
    
' Check for the flag being set in the KeyDown event.
    If nonNumberEntered = True Then
        
' Stop the character from being entered into the control since it is non-numerical.
        e.Handled = True
    
End If
End Sub
 'textBox1_KeyPress
End Class 'Form1 
[C#] 
// Boolean flag used to determine when a character other than a number is entered.
private bool nonNumberEntered = false;

// Handle the KeyDown event to determine the type of character entered into the control.
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
    
// Initialize the flag to false.
    nonNumberEntered = false;

    
// Determine whether the keystroke is a number from the top of the keyboard.
    if (e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9)
    
{
        
// Determine whether the keystroke is a number from the keypad.
        if (e.KeyCode < Keys.NumPad0 || e.KeyCode > Keys.NumPad9)
        
{
            
// Determine whether the keystroke is a backspace.
            if(e.KeyCode != Keys.Back)
            
{
                
// A non-numerical keystroke was pressed.
                
// Set the flag to true and evaluate in KeyPress event.
                nonNumberEntered = true;
            }

        }

    }

}


// This event occurs after the KeyDown event and can be used to prevent
// characters from entering the control.
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
    
// Check for the flag being set in the KeyDown event.
    if (nonNumberEntered == true)
    
{
        
// Stop the character from being entered into the control since it is non-numerical.
        e.Handled = true;
    }

}

[C++
// Boolean flag used to determine when a character other than a number is entered.
private:
bool nonNumberEntered;

// Handle the KeyDown event to determine the type of character entered into the control.
void textBox1_KeyDown(Object* /*sender*/, System::Windows::Forms::KeyEventArgs* e)
{
   
// Initialize the flag to false.
   nonNumberEntered = false;

   
// Determine whether the keystroke is a number from the top of the keyboard.
   if (e->KeyCode < Keys::D0 || e->KeyCode > Keys::D9)
   
{
      
// Determine whether the keystroke is a number from the keypad.
      if (e->KeyCode < Keys::NumPad0 || e->KeyCode > Keys::NumPad9)
      
{
         
// Determine whether the keystroke is a backspace.
         if(e->KeyCode != Keys::Back)
         
{
            
// A non-numerical keystroke was pressed.
            
// Set the flag to true and evaluate in KeyPress event.
            nonNumberEntered = true;
         }

      }

   }

}


// This event occurs after the KeyDown event and can be used to prevent
// characters from entering the control.
void textBox1_KeyPress(Object* /*sender*/, System::Windows::Forms::KeyPressEventArgs* e)
{
   
// Check for the flag being set in the KeyDown event.
   if (nonNumberEntered == true)
   
{
      
// Stop the character from being entered into the control since it is non-numerical.
      e->Handled = true;
   }

}

[JScript] 沒有可用于 JScript 的示例。若要查看 Visual Basic、C# 或 C++ 示例,請(qǐng)單擊頁左上角的“語言篩選器”按鈕 語言篩選器

要求

平臺(tái): Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 系列

請(qǐng)參見

Control 類 | Control 成員 | System.Windows.Forms 命名空間 | OnKeyPress

posted on 2007-05-17 00:02 譚文政 閱讀(1167) 評(píng)論(0)  編輯 收藏 引用 所屬分類: vc++.net
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国产区亚洲区欧美区| 亚洲一区观看| 欧美中文字幕在线| 欧美精品一区二区精品网| 国产人成精品一区二区三| 亚洲精品视频一区| 久久久久久成人| 99视频在线精品国自产拍免费观看 | 亚洲电影免费观看高清完整版在线观看| 宅男66日本亚洲欧美视频| 男女av一区三区二区色多| 亚洲欧美日本视频在线观看| 欧美日韩在线观看一区二区| 亚洲国产欧美不卡在线观看| 久久青草久久| 亚洲女人小视频在线观看| 欧美三级网址| 99精品热6080yy久久| 欧美国产视频一区二区| 久久精品国产一区二区三区| 国产噜噜噜噜噜久久久久久久久 | 欧美fxxxxxx另类| 欧美一区国产在线| 国产精品五月天| 亚洲欧美电影在线观看| 99re这里只有精品6| 免费在线欧美黄色| 欧美在线免费| 亚洲欧美国产三级| 国产精品九色蝌蚪自拍| 一本色道综合亚洲| 亚洲精品女av网站| 性欧美8khd高清极品| 国产精品羞羞答答xxdd| 亚洲欧美综合精品久久成人| aa级大片欧美三级| 欧美四级在线观看| 宅男在线国产精品| 9i看片成人免费高清| 欧美三级日韩三级国产三级| 在线一区二区三区四区五区| 亚洲乱码国产乱码精品精可以看| 欧美精品在线观看一区二区| 日韩一二三在线视频播| 亚洲精品护士| 欧美日韩精品一区视频| 亚洲私人影院| 中文精品在线| 国产欧美日韩一区二区三区在线| 欧美在线观看视频一区二区三区| 亚洲欧美网站| 韩国一区二区三区美女美女秀| 久久香蕉精品| 久热精品视频在线观看一区| 亚洲欧洲一区二区三区在线观看| 亚洲黄色毛片| 欧美三级日本三级少妇99| 亚洲欧美网站| 欧美在线观看网站| 亚洲国产另类久久精品| 亚洲国产精品一区制服丝袜| 欧美日韩精品一区二区三区| 午夜在线精品| 久久久久.com| 亚洲激情av在线| 欧美国产日本韩| 亚洲午夜久久久| 亚洲欧美一区二区三区在线 | 欧美国产日韩精品免费观看| 欧美精品一区三区| 亚洲欧美资源在线| 久久精品在线| 99国产精品视频免费观看| 国产精品99久久久久久宅男 | 久久久久国产一区二区| 永久555www成人免费| 亚洲激情第一区| 国产精品乱码一区二三区小蝌蚪| 久久久久久一区二区三区| 免费不卡中文字幕视频| 亚洲午夜av电影| 性色av一区二区三区红粉影视| 亚洲风情亚aⅴ在线发布| 亚洲精品资源| 国产欧美日韩在线视频| 欧美国产精品久久| 国产精品久久久久久久久免费樱桃| 久久精品视频在线观看| 欧美高清在线精品一区| 欧美一区91| 欧美14一18处毛片| 欧美一区二区三区在线免费观看| 久久永久免费| 亚洲欧美日本国产有色| 噜噜噜在线观看免费视频日韩 | 在线观看视频一区二区| 99精品国产在热久久下载| 国产自产在线视频一区| 久久九九国产精品怡红院| 亚洲精品乱码久久久久久日本蜜臀 | 久久嫩草精品久久久精品一| 欧美另类一区| 久久综合狠狠| 欧美精品一区三区| 美国成人毛片| 国产精品任我爽爆在线播放| 亚洲电影天堂av| 国产精品自拍视频| 亚洲激情欧美| 尤物在线观看一区| 亚洲网站在线播放| 亚洲美女黄网| 久久久亚洲成人| 欧美一级二区| 欧美日韩精品国产| 欧美福利网址| 国产精品午夜av在线| 99成人在线| 亚洲精品国产欧美| 久久国产欧美| 欧美一区二区黄| 欧美日韩蜜桃| 亚洲国产成人一区| 曰本成人黄色| 欧美伊人久久| 亚洲免费在线电影| 欧美激情视频在线免费观看 欧美视频免费一| 久久精品国产99| 国产精品三级久久久久久电影| 亚洲精品一区二区三区婷婷月| 欧美a级理论片| 国内精品99| 性色av一区二区三区| 先锋a资源在线看亚洲| 欧美午夜寂寞影院| 日韩亚洲欧美在线观看| 亚洲精品小视频| 男人天堂欧美日韩| 欧美大片91| 亚洲大胆av| 久久久久欧美精品| 久久网站热最新地址| 国产亚洲一级| 先锋资源久久| 久久xxxx| 国产日韩综合一区二区性色av| 亚洲视屏一区| 亚洲欧洲99久久| 国产精品视频免费观看www| 一区二区三区回区在观看免费视频| 一区二区激情| 欧美三级黄美女| 亚洲色图综合久久| 亚洲欧美三级伦理| 国产精品欧美一区二区三区奶水| 宅男在线国产精品| 午夜国产精品影院在线观看| 国产精品日韩二区| 亚洲欧美日韩一区| 久久久精品日韩欧美| 国产一区在线播放| 久久精品一区二区三区中文字幕| 毛片精品免费在线观看| 亚洲黄色成人| 欧美精品一区二| 一区二区三区蜜桃网| 午夜精品影院| 国内精品福利| 卡通动漫国产精品| 亚洲欧洲中文日韩久久av乱码| 99在线精品观看| 欧美日韩一级大片网址| 亚洲一区二区不卡免费| 久久亚洲春色中文字幕| 久久久久高清| 亚洲国产成人av在线| 欧美激情第4页| 日韩亚洲综合在线| 欧美在线一区二区| 国产欧美在线观看一区| 久久久久久久999精品视频| 欧美国产先锋| 一区二区三区www| 国产精品永久| 久久久之久亚州精品露出| 亚洲国产精品传媒在线观看| 一区二区三区国产| 国产精品永久免费| 久久女同精品一区二区| 亚洲日本va午夜在线影院| 中日韩在线视频| 国产日本欧美一区二区| 美女图片一区二区| 99天天综合性| 久久综合给合久久狠狠狠97色69| 亚洲久久一区二区| 国产精品色婷婷| 久久久久免费| 一本色道久久综合亚洲精品小说| 久久都是精品|