文本框有橫向文本框和豎向文本框兩種方式,用戶(hù)可以根據自己的需要,選擇插入橫向文本框或者豎向文本框。
Microsoft Office Word都是最流行的文字處理程序。作為Office套件的核心程序, Word提供了許多易于使用的文檔創(chuàng )建工具,同時(shí)也提供了豐富的功能集供創(chuàng )建復雜的文檔使用。哪怕只使用Word應用一點(diǎn)文本格式化操作或圖片處理,也可以使簡(jiǎn)單的文檔變得比只使用純文本更具吸引力。
擴展資料
Word中的文本框
在Word中文本框是指一種可移動(dòng)、可調大小的文字或圖形容器。使用文本框,可以在一頁(yè)上放置數個(gè)文字塊,或使文字按與文檔中其他文字不同的方向排列。
PowerPoint中的文本框
在PowerPoint中,文本框是已經(jīng)存在的,可以直接在文本框內編輯文字。文本框可以拖動(dòng),改變大小(文本框內的文字不改變大小)。當然你也可以不使用既得的文本框而新建文本框。方法是:?jiǎn)螕舨迦耄x擇文本框即可。
private void tBox_KeyPress(object sender, KeyPressEventArgs e){if (e.KeyChar == 0x20) e.KeyChar = (char)0; //禁止空格鍵
if (e.KeyChar > 0x20){try{double.Parse(((TextBox)sender).Text + e.KeyChar.ToString());}catch{
e.KeyChar = (char)0; //處理非法字符}}}private void TextBox_KeyPress(object sender, KeyPressEventArgs e){if(e.KeyChar!=8&&!Char.IsDigit(e.KeyChar)){
e.Handled = true;}}或者private void TextBox_KeyPress(object sender, KeyPressEventArgs e){if(e.KeyChar!='\b'&&!Char.IsDigit(e.KeyChar)){
e.Handled = true;}}private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e){if(e.KeyChar!='\b')//這是允許輸入退格鍵{if((e.KeyChar'9'))//這是允許輸入0-9數字{
e.Handled = true;}}}private void button1_Click(object sender, EventArgs e){string text = this.textBox1.Text;
if (text != null)
MessageBox.Show(text);}private void textBox1_Validating(object sender, CancelEventArgs e){const string pattern = @"^\d+\.?\d+$";
string content = ((TextBox)sender).Text;
if (!(Regex.IsMatch(content, pattern))){errorProvider1.SetError((Control)sender, "只能輸入數字!");
e.Cancel = true;}elseerrorProvider1.SetError((Control)sender, null);}private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e){if(e.KeyChar=='.' && this.textBox1.Text.IndexOf(".")!=-1){
e.Handled=true;}if(!((e.KeyChar>=48 && e.KeyChar=57) && (e.KeyChar != 8) && (e.KeyChar != 46))
================48代表0,57代表9,8代表空格,46代表小數點(diǎn)}
系統按鈕(例如,箭頭鍵和功能鍵)無(wú)法得到識別-->TextBox ID="TextBox1" runat="server" onkeypress="isNum();" > 后臺代碼: protected void Button1_Click(object sender, EventArgs e){try {double num=Convert.ToDouble(TextBox1.Text);}catch (Exception){Page.ClientScript.RegisterStartupScript(this.GetType(),"alertNum", "");TextBox1.Text = "";Page.ClientScript.RegisterStartupScript(this.GetType(),"focus", "");}} 第一種:try catch方法例:try{Convert.ToInt32("123"):Console.Write("是數字");}catch(Exception ex){Console.Write("非數字");}注:如果有很多字符串要求判斷,此方法需要大量的try catch 以及finally來(lái)處理后續的程序.不建議使用此方法。
第二種:正則表達式方法例://引用正則表達式類(lèi)using System.Text.RegularExpressions;Regex reg=new Regex("^[0-9]+$");Match ma=reg.Match(text);if(ma.Success){//是數字}else{//不是數字}注:此方法快捷,但不太容易掌握,尤其是正則表達式公式,如果有興趣的朋友可以好好研究,這東西很好用的,建議使用。第三種:Double.TryParse方法例:bool isNum=System.Double.TryParse("所要判斷的字符串" ,System.Globalization.NumberStyles.Integer,null,out );注:此方法快捷,方便,很容易被掌握,但是參數很多,有興趣的朋友可以研究一下,建議使用。
NumberStyles枚舉:Integer指示使用 AllowLeadingWhite、AllowTrailingWhite 和 AllowLeadingSign 樣式。這是復合數字樣式。
聲明:本網(wǎng)站尊重并保護知識產(chǎn)權,根據《信息網(wǎng)絡(luò )傳播權保護條例》,如果我們轉載的作品侵犯了您的權利,請在一個(gè)月內通知我們,我們會(huì )及時(shí)刪除。
蜀ICP備2020033479號-4 Copyright ? 2016 學(xué)習?shū)B(niǎo). 頁(yè)面生成時(shí)間:3.205秒