在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
void textBox2_KeyDown(object sender,KeyEventArgs e) { Control ctr= (Control)sender; switch (e.KeyData) { case Keys.Right: if (ctr.Right == 0) { MessageBox.Show("已到顶"); } else { ctr.Location = new Point(ctr.Location.X + 5, ctr.Location.Y + 5); } break; case Keys.Up: if (ctr.Top == 0) { MessageBox.Show("已到顶"); } else { //ctr.Top -= 5; ctr.Location = new Point(ctr.Location.X, ctr.Location.Y - 5); } break; case Keys.Down: if (ctr.Bottom == 0) { MessageBox.Show("已到顶"); } else { //ctr.Top += 5; ctr.Location = new Point(ctr.Location.X, ctr.Location.Y + 5); } break; case Keys.Left: if (ctr.Left == 0) { MessageBox.Show("已到顶"); } else { //ctr.Left -= 5; ctr.Location = new Point(ctr.Location.X - 5, ctr.Location.Y); } break; } if (e.KeyCode == Keys.Right) { if (ctr.Top == 0) { MessageBox.Show("已到顶"); } else { ctr.Top -= 5; } } }
|
请发表评论