按回车键时,焦点跳到dropdownlist控件上,同时,该控件的下拉菜单选项自动展开
请高手们帮帮忙啊!
6 个解决方案
#1
public Form1()
{
InitializeComponent();
this.Load += new EventHandler(Form1_Load);
this.KeyUp+=new KeyEventHandler(Form1_KeyUp);
}
void Form1_Load(object sender, EventArgs e)
{
this.KeyPreview = true;
comboBox1.Items.Add("sd1");
comboBox1.Items.Add("sd2");
comboBox1.Items.Add("sd3");
comboBox1.Items.Add("aaaaasdassd3");
}
void Form1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
comboBox1.Focus();
comboBox1.DroppedDown=true;
}
}
#2
mngzilin:不好意思,首先,我要的是在WebForm下实现,其次,不是comboBox控件,而是dropdownlist控件
继续请教高手
继续请教高手
#3
看看这个网页吧,你要的功能只能模拟!
http://hi.baidu.com/top147/blog/item/ebddb6cafe360487c81768a6.html
http://hi.baidu.com/top147/blog/item/ebddb6cafe360487c81768a6.html
#4
up
#5
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script>
function exp(obj)
{
var WshShell = new ActiveXObject("Wscript.Shell");
try{
WshShell.SendKeys("%{DOWN}");
}
catch(e){}
WshShell.Quit;
}
function kkk()
{
if(event.keyCode==13)
document.getElementById("DropDownList1").focus();
}
</script>
</head>
<body onkeyup="kkk();">
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" onfocus="exp(this);" >
<asp:ListItem>fasf</asp:ListItem>
<asp:ListItem>fasf</asp:ListItem>
<asp:ListItem>fasf</asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>
<head runat="server">
<title>无标题页</title>
<script>
function exp(obj)
{
var WshShell = new ActiveXObject("Wscript.Shell");
try{
WshShell.SendKeys("%{DOWN}");
}
catch(e){}
WshShell.Quit;
}
function kkk()
{
if(event.keyCode==13)
document.getElementById("DropDownList1").focus();
}
</script>
</head>
<body onkeyup="kkk();">
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" onfocus="exp(this);" >
<asp:ListItem>fasf</asp:ListItem>
<asp:ListItem>fasf</asp:ListItem>
<asp:ListItem>fasf</asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>
#6
回复mngzilin:
运行出错,提示:Automation服务器不能创建对象
还请指教
运行出错,提示:Automation服务器不能创建对象
还请指教
#1
public Form1()
{
InitializeComponent();
this.Load += new EventHandler(Form1_Load);
this.KeyUp+=new KeyEventHandler(Form1_KeyUp);
}
void Form1_Load(object sender, EventArgs e)
{
this.KeyPreview = true;
comboBox1.Items.Add("sd1");
comboBox1.Items.Add("sd2");
comboBox1.Items.Add("sd3");
comboBox1.Items.Add("aaaaasdassd3");
}
void Form1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
comboBox1.Focus();
comboBox1.DroppedDown=true;
}
}
#2
mngzilin:不好意思,首先,我要的是在WebForm下实现,其次,不是comboBox控件,而是dropdownlist控件
继续请教高手
继续请教高手
#3
看看这个网页吧,你要的功能只能模拟!
http://hi.baidu.com/top147/blog/item/ebddb6cafe360487c81768a6.html
http://hi.baidu.com/top147/blog/item/ebddb6cafe360487c81768a6.html
#4
up
#5
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script>
function exp(obj)
{
var WshShell = new ActiveXObject("Wscript.Shell");
try{
WshShell.SendKeys("%{DOWN}");
}
catch(e){}
WshShell.Quit;
}
function kkk()
{
if(event.keyCode==13)
document.getElementById("DropDownList1").focus();
}
</script>
</head>
<body onkeyup="kkk();">
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" onfocus="exp(this);" >
<asp:ListItem>fasf</asp:ListItem>
<asp:ListItem>fasf</asp:ListItem>
<asp:ListItem>fasf</asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>
<head runat="server">
<title>无标题页</title>
<script>
function exp(obj)
{
var WshShell = new ActiveXObject("Wscript.Shell");
try{
WshShell.SendKeys("%{DOWN}");
}
catch(e){}
WshShell.Quit;
}
function kkk()
{
if(event.keyCode==13)
document.getElementById("DropDownList1").focus();
}
</script>
</head>
<body onkeyup="kkk();">
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" onfocus="exp(this);" >
<asp:ListItem>fasf</asp:ListItem>
<asp:ListItem>fasf</asp:ListItem>
<asp:ListItem>fasf</asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>
#6
回复mngzilin:
运行出错,提示:Automation服务器不能创建对象
还请指教
运行出错,提示:Automation服务器不能创建对象
还请指教