您当前的位置:中客资源站网络学院.NET专区综合应用 → 文章内容 退出登录 用户管理
本类热门文章
相关下载
VS.NET 2005 Beta2初体验(4)-Notification控件
作者:中客资源  来源:中客资源  发布时间:2007-2-7 2:54:09

减小字体 增大字体

今天的主题是Notification,这是Windows CE所特有的一种消息通知方式。消息支持文本和HTML形式,当有消息出现的时候会出现一个气泡式的窗体。在以前的VS.NET 2003里,发送Notification,的主要方式是调用API或者使用OpenNETCF中的相关类。而.NET CF 2.0目前支持了托管方式的Notification

我们首先在工具栏里找到Notification控件,并将它拖到窗体中,该控件将显示到窗体下面,和菜单控件在一起。

         private void button1_Click(object sender, EventArgs e)

         {

              StringBuilder HTMLString = new StringBuilder();

              HTMLString.Append("<html><body>");

              HTMLString.Append("Submit data?");

              HTMLString.Append("<form method=\'GET\' action=notify>");

              HTMLString.Append("<input type='submit'>");

              HTMLString.Append("<input type=button name='cmd:2' value='Cancel'>");

              HTMLString.Append("</body></html>");

              //Set the Text property to the HTML string.

              notification1.Text = HTMLString.ToString();

              notification1.Caption = "Notification Demo";

              notification1.Critical = false;

              // Display icon up to 10 seconds.

              notification1.InitialDuration = 10;

              notification1.Visible = true;

         }

我们在窗体上添加一个Button和一个TextBox,在Button的响应函数中加入上面的代码。这些代码是来自于MSDN

然后我们再添加Notification控件的事件响应函数。选中Notification控件,在属性窗口中选择“事件”(那个闪电型的图标),然后双击ResponseSubmitted事件。

在事件处理函数中添加下面的代码:

         private void notification1_ResponseSubmitted(object sender, Microsoft.WindowsCE.Forms.ResponseSubmittedEventArgs e)

         {

              if (e.Response.Substring(0, 6) == "notify")

              {

                   // Add code here to respond to the notification.

                   textBox1.Text = e.Response.ToString();

              }

         }


[] [返回上一页] [打 印]
文章评论 (评论内容只代表网友观点,与本站立场无关!)

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码