设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 2012|回复: 1
打印 上一主题 下一主题

【作业】01课-ET_ET

[复制链接]
跳转到指定楼层
1#
发表于 2014-3-5 16:56:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 ET_ET 于 2014-3-5 16:58 编辑

CA-705D 作业...
  1. using Microsoft.Office.Tools.Ribbon;
  2. using System.Diagnostics;

  3. namespace WordAddIn1
  4. {
  5.     public partial class myFirstRibbon
  6.     {
  7.         private Process myProc = new Process();
  8.         private bool hasNotepad = false;


  9.         private void myFirstRibbon_Load(object sender, RibbonUIEventArgs e)
  10.         {
  11.             myProc.StartInfo.FileName = "notepad";
  12.             myProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
  13.             button1.OfficeImageId = "NextPageOneNote";
  14.         }

  15.         private void button1_Click(object sender, RibbonControlEventArgs e)
  16.         {
  17.             RibbonButton btn = (RibbonButton)sender;
  18.             if (!hasNotepad)
  19.             {
  20.                 myProc.Start();
  21.                 btn.Label = "关闭后台记事本";
  22.                 btn.OfficeImageId = "ClearRow";
  23.             }
  24.             else
  25.             {
  26.                 myProc.Kill();
  27.                 btn.Label = "后台打开记事本";
  28.                 btn.OfficeImageId = "NextPageOneNote";
  29.             }
  30.             hasNotepad = !hasNotepad;
  31.             
  32.         }

  33.         private void button2_Click(object sender, RibbonControlEventArgs e)
  34.         {
  35.             string myTry;
  36.             myTry = this.checkBox1.Checked ? "http://www.office-cn.net" : "http://yy.com/91283328/2175343697?from=";

  37.             try
  38.             {
  39.                 Process.Start(myTry);
  40.             }
  41.             catch (System.Exception ex)
  42.             {
  43.                 System.Windows.Forms.MessageBox.Show(ex.Message);
  44.             }
  45.         }

  46.         private void checkBox1_Click(object sender, RibbonControlEventArgs e)
  47.         {
  48.             string lbl = checkBox1.Checked ? "打开Office中国" : "    打开YY   ";
  49.             checkBox1.Label = lbl;
  50.             button2.Label = lbl;
  51.         }
  52.     }
  53. }
复制代码


评分

参与人数 1V币 +1 收起 理由
faunus + 1 (V币)课程报名、录像学习、代码练习跟贴.

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2014-3-7 23:09:49 | 只看该作者

西西题目有问题。
这位童鞋竟然会用3元运算符,很有前途啊。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-5 23:15 , Processed in 0.085716 second(s), 27 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表