◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
创业资讯门户网站
今天给各位分享textbox的知识,其中也会对textbox是什么意思啊进行解释,如果能碰巧解决你现在面临的问题,别忘了关注佰雅经济,现在开始吧!
1、单个删除方法。textbox在excel里可以直接删除,方法是,按下ctrl键,选中文本框,然后按delete键删除,或者按退格键删除。
2、批量删除方法,按F5调出定位对话框,定位条件选择对象,确定以后,在excel中存在的对象全部被选中,按下delete键删除。
textbox.Text = "用户名";//设置默认值
//Enter事件:当窗体的控件成为活动控件时发生
//即一旦选定textbox即发生Enter事件
private void textBox_Enter(object sender, EventArgs e)
{
if(text,Text == "用户名")
{
textbox.Text = "";
}
}
1)在Form1上拖入两个TexBox,分别为textBox1和textBox2。textBox1用来显示输入的文本;textBox2用来输入文本。
2)在Form1.cs中添加一个类TextUndoBuffer。代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
TextUndoBuffer buffer;
private void Form1_Load(object sender, EventArgs e)
{
buffer = new TextUndoBuffer();
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
//按下Ctrl+z,取消最近一次输入的内容
if (e.KeyCode == Keys.Z e.Modifiers == Keys.Control)
{
buffer.Undo();
textBox1.Text = buffer.GetAll();
}
}
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Return)
{
string s = textBox2.Text.Trim();
if (s != string.Empty)
{
buffer.PutInBuffer(" " + textBox2.Text.Trim());
textBox2.Clear();
textBox1.Text = buffer.GetAll();
}
}
}
}
/// summary
/// 这个类用来记录输入的内容并支持Undo
/// /summary
class TextUndoBuffer
{
Liststring buffer;
public TextUndoBuffer()
{
this.buffer = new Liststring();
}
/// summary
/// 将输入的一句话放入缓冲区
/// /summary
/// param name="s"/param
public void PutInBuffer(string s)
{
this.buffer.Add(s);
}
/// summary
/// 从缓冲区获取所有输入的内容
/// /summary
/// returns/returns
public string GetAll()
{
string s = string.Empty;
foreach (var q in this.buffer)
{
s += q;
}
return s;
}
/// summary
/// Undos实现取消最近一次输入的内容
/// /summary
public void Undo()
{
if (this.buffer.Count == 0) return;
buffer.RemoveAt(this.buffer.Count - 1);
}
}
}
3)事件处理
注意:textBox1和textBox2“共用”了同一个KeyDown事件处理函数,详细见上面代码
开发工具 —— 插入——下面有两组控件,上面一组是表单控件,里面有textbox,下面一组是activex控件,里面也有textbox。如果需要在窗体上使用控件,一般使用下面的AcitveX控件。
如果找不到开发工具选项卡,则需要到选项-自定义里面将其显示出来。
1、点击textbox,在属性中把MultiLine属性设置为True,如下图;
2、在属性中设置ScrollBars的值,一般选择2-Vertical,你可以根据自己需要选择。
textbox的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于textbox是什么意思啊、textbox的信息别忘了在本站进行查找喔。
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。