WebBrowser Ctrl + Enter的快捷键 [英] Shortcut key for WebBrowser ctrl+enter
问题描述
朋友,
好吧,朋友,我正在一个名为WebBrowser的项目上工作,现在我想向我的项目中添加一些快捷键,例如"Ctrl + Enter".当用户在地址文本框url上输入一些网站名称时,它应直接重定向到整个网址名称就像我们通常键入"Yahoo"一样,然后ctrl +输入其重定向到http://www.yahoo.com,所以我也想对我的项目实施相同的快捷方式.
我正在使用Visual Studio2010.
朋友请帮助..
在此先感谢:)
Hi Friends,
Well, Friends i,am working on a project called WebBrowser and now i wants to add some shortcut keys to my project like "Ctrl+Enter" When the user type some websites name on address textbox url its should directly redirect to entire web address name like we normally do type "Yahoo" then ctrl+enter its redirect to http://www.yahoo.com so i want to implement same shortcut to my project as well.
I''am Using Visual Studio 2010.
Friends Plz help..
Thanks in Advance:)
推荐答案
使用文本框的keydown事件////我想您正在使用文本框控件输入URL
Use the keydown event of textbox // i suppose you are using a textbox control for entering URL
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Enter) // to check whether cntrl key + enter key are pressed
textBox1.Text = "http://www." + textBox1.Text + ".com";
// Now use this textbox text to redirect
}
}
---- Prathap.
----Prathap.
尼克尔,
这应该可以正常工作.一切似乎都还可以.但是连接后,您没有导航文本.
Hi Nikhil,
This should work fine.Everything seems ok.But you didn''t navigate the text after concatenation.
private void adrBarTextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
getCurrentBrowser().Navigate(adrBarTextBox.Text);
}
else
{
if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Enter)
{
adrBarTextBox.Text = "http://www." + adrBarTextBox.Text + ".com";
getCurrentBrowser().Navigate(adrBarTextBox.Text);
}
}
}
如果这不起作用,请先尝试代码,然后按Cntrl + Enter键后检查文本框文本是否已串联
If this is not working.First just try the code and check whether the textbox text is concatenated after pressing Cntrl+Enter key
if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Enter) // to check whether cntrl key + enter key are pressed
textBox1.Text = "http://www." + textBox1.Text + ".com";
这篇关于WebBrowser Ctrl + Enter的快捷键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!