急,求助!关于用VS C# 2005写PPC应用程序,该如何修改下面代码,使当焦点在某个Button控件时,该控件的背景颜色会变成蓝
private void textBox1_Press(object sender, KeyEventArgs e){
Control ctrl = (Control)sender;
if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
{
this.SelectNextControl(ctrl, true, true, true, true);
MessageBox.Show("当前焦点的控件:" + FindFocusedControl(this).Name);
}
}
private void button1_Press(object sender, KeyEventArgs e)
{
Control ctrl = (Control)sender;
if ((e.KeyCode == System.Windows.Forms.Keys.Down))
{
this.SelectNextControl(ctrl, true, true, true, true);
this.button1.BackColor = System.Drawing.Color.LightSkyBlue;
}
if ((e.KeyCode == System.Windows.Forms.Keys.Up))
{
this.SelectNextControl(ctrl, false, true, true, true);
this.button1.BackColor = System.Drawing.Color.Gainsboro;
}
//按回车要做的事儿
if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
{
this.Close();
// MessageBox.Show("当前焦点的控件:" + FindFocusedControl(this).Name);
}
if ((e.KeyCode == System.Windows.Forms.Keys.Left))
{
// 向左键
MessageBox.Show("当前焦点的控件:" + FindFocusedControl(this).Name);
}
}
private void button2_Press(object sender, KeyEventArgs e)
{
Control ctrl = (Control)sender;
if ((e.KeyCode == System.Windows.Forms.Keys.Down))
{
this.SelectNextControl(ctrl, true, true, true, true);
}
if ((e.KeyCode == System.Windows.Forms.Keys.Up))
{
this.SelectNextControl(ctrl, false, true, true, true);
}
//按回车要做的事儿
if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
{
MessageBox.Show("当前焦点的控件:" + FindFocusedControl(this).Name);
}
}
private void button3_Press(object sender, KeyEventArgs e)
{
Control ctrl = (Control)sender;
if ((e.KeyCode == System.Windows.Forms.Keys.Down))
{
this.SelectNextControl(ctrl, true, true, true, true);
}
if ((e.KeyCode == System.Windows.Forms.Keys.Up))
{
this.SelectNextControl(ctrl, false, true, true, true);
}
//按回车要做的事儿
if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
{
MessageBox.Show("当前焦点的控件:" + FindFocusedControl(this).Name);
}
}
public static Control FindFocusedControl(Control container)
{
foreach (Control childControl in container.Controls)
{
if (childControl.Focused)
{
return childControl;
}
}
return null;
}
麻烦给出详细的操作以及代码! --------------------编程问答-------------------- 学习并帮顶 --------------------编程问答-------------------- 没太看懂。你这样能实现你的效果?而且,代码太冗余了。 --------------------编程问答-------------------- 获得焦点就修改背景不行吗 --------------------编程问答-------------------- 如梦的思路不错。获取焦点和失去焦点时候修改背景色。 --------------------编程问答-------------------- PPC是小型设备,用手写笔的,怎么触发“在按钮上面”,难道是手写笔从屏幕别的地方滑动到按钮上?不解 --------------------编程问答-------------------- 哦,是用方向键做的,明白了。我以前写过PPC的,PPC的和PC的不一样 --------------------编程问答-------------------- 请问楼主有没有将ppc程序安装到实物上,我打包成CAB安装后,exe无法运行、。
补充:.NET技术 , C#