C# 鍵盤Enter鍵取代Tab鍵實現(xiàn)代碼
更新時間:2013年11月29日 15:36:22 作者:
這篇文章主要介紹了C# 鍵盤Enter鍵取代Tab鍵實現(xiàn)代碼,有需要的朋友可以參考一下
說明:在填寫表數(shù)據(jù)時當(dāng)輸入完一個文本框后,輸入下一個文本框時需要用Tab鍵切換,但是有的人喜歡用Enter鍵切換下一個,此方法是Enter取代Tab鍵。
效果:
注釋:鍵盤Enter鍵數(shù)字為:13
鍵盤Tab鍵數(shù)字為:9
函數(shù)代碼:
復(fù)制代碼 代碼如下:
private void SetEnt()
{
foreach (Control txt in (this.Page.Form.FindControl("ContentPlaceHolderEntity")).Controls)
{
if (txt is System.Web.UI.WebControls.TextBox)
{
if (((TextBox)txt).CssClass != "erp_textarea")
((TextBox)txt).Attributes.Add("onkeydown", "if (window.event.keyCode==13) window.event.keyCode=9");
}
if (txt is System.Web.UI.WebControls.DropDownList)
{
((DropDownList)txt).Attributes.Add("onkeydown", "if (window.event.keyCode==13) window.event.keyCode=9");
}
if (txt is System.Web.UI.WebControls.CheckBox)
{
((CheckBox)txt).Attributes.Add("onkeydown", "if (window.event.keyCode==13) window.event.keyCode=9");
}
}
}
相關(guān)文章
C#正則過濾HTML標(biāo)簽并保留指定標(biāo)簽的方法
這篇文章主要介紹了C#正則過濾HTML標(biāo)簽并保留指定標(biāo)簽的方法,涉及C#針對頁面HTML元素正則匹配與替換相關(guān)操作技巧,需要的朋友可以參考下2017-06-06WinForm中comboBox控件數(shù)據(jù)綁定實現(xiàn)方法
這篇文章主要介紹了WinForm中comboBox控件數(shù)據(jù)綁定實現(xiàn)方法,結(jié)合實例形式分析了WinForm實現(xiàn)comboBox控件數(shù)據(jù)綁定的常用方法與相關(guān)操作技巧,需要的朋友可以參考下2017-05-05WPF拖動DataGrid滾動條時內(nèi)容混亂的解決方法
這篇文章主要介紹了WPF拖動DataGrid滾動條時內(nèi)容混亂的解決方法2016-10-10C#中將字符串轉(zhuǎn)換為整型的三種解決方法總結(jié)
本篇文章是對C#中將字符串轉(zhuǎn)換為整型的三種解決方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06