1.RichTextBox插入字体编辑颜色,连接的数据库,读取数据库里的内容
public void nowperson()
{
now.Clear(); // 清除文本内容
Dao dao = new Dao();
string sql = "select top 1 * from dbo.Wait where Condition = '未完成' OR Condition = '置顶' order by Condition DESC,RealTime";
IDataReader dc = dao.read(sql);
while (dc.Read())
{
//now.BulletIndent = 30;//指定文本距离控件最左边缩进30个像素
//now.SelectionBullet = true; // 指定后面插入的文本开始进行缩进
now.SelectionFont = new Font("楷体", 60);//设置当前插入文本为楷体60号字体
now.SelectionColor = Color.Red; // 设定插入文本的颜色
now.SelectionAlignment = HorizontalAlignment.Center; //设置文本居中
now.SelectedText = dc[1].ToString() + "\t"; // 插入的文本内容,空格
now.SelectionFont = new Font("楷体", 72);//设置当前插入文本楷体72号字体
now.SelectionColor = Color.Red; // 设定插入文本的颜色
now.SelectedText = dc[2].ToString() + "\n"; // 插入的文本内容,换行
//now.SelectionBullet = false;//关闭缩进
//now.SelectionFont = new Font("Verdana", 10);//重新设定字体
//now.SelectedText = "The bulleted text is indented 30 pixels from the bullet symbol using the BulletIndent property.\n";//插入文本
}
dc.Close();
dao.DaoClose();
}
2.计时器
用到了一个组件Timer,用于定时刷新等
需要工作时Enabled设置为true
Interval为刷新频率,单位为毫秒,1000ms为1s
之后双击把需要定时刷新的内容放入即可
private void timer1_Tick(object sender, EventArgs e)
{
nowperson();
allpeople();
}
3.当前时间显示
也是计时器的用法,拖入timer添加事件即可,拖入label作为显示的容器
private void showtime_Tick(object sender, EventArgs e)
{
label3.Text = DateTime.Now.ToString();
}