您好,登錄后才能下訂單哦!
this.KeyPreview = true;
this.MouseWheel += new MouseEventHandler(Form1_MouseWheel);
this.KeyPreview = true是要讓窗體優(yōu)先響應(yīng)按鍵事件。
void Form1_MouseWheel(object sender, MouseEventArgs e) { if (e.Delta > 0) { ShowPrevPicture(); } else { ShowNextPicture(); } }
我這里是讓鼠標(biāo)滾輪往下滾時顯示下一張圖,往上滾時顯示上一張。
按鍵事件的話需要重載ProcessDialogKey函數(shù)
protected override bool ProcessDialogKey(Keys keyData) { switch (keyData) { case Keys.Left: case Keys.Up: ShowPrevPicture(); return true; case Keys.Right: case Keys.Down: case Keys.Enter: ShowNextPicture(); return true; case Keys.Delete: DeleteCurrentPicutreFromHardDisk(); return true; case Keys.Subtract: DownImageLevel(PictureList.ElementAt(curIndex)); DeleteCurrentPicutureFromShowList(); return true; case Keys.Add: case Keys.Insert: UpImageLevel(PictureList.ElementAt(curIndex)); DeleteCurrentPicutureFromShowList(); return true; } return false; }
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。