Office中国论坛/Access中国论坛
标题:
【作业】01课-ET_ET
[打印本页]
作者:
ET_ET
时间:
2014-3-5 16:56
标题:
【作业】01课-ET_ET
本帖最后由 ET_ET 于 2014-3-5 16:58 编辑
CA-705D 作业...
using Microsoft.Office.Tools.Ribbon;
using System.Diagnostics;
namespace WordAddIn1
{
public partial class myFirstRibbon
{
private Process myProc = new Process();
private bool hasNotepad = false;
private void myFirstRibbon_Load(object sender, RibbonUIEventArgs e)
{
myProc.StartInfo.FileName = "notepad";
myProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
button1.OfficeImageId = "NextPageOneNote";
}
private void button1_Click(object sender, RibbonControlEventArgs e)
{
RibbonButton btn = (RibbonButton)sender;
if (!hasNotepad)
{
myProc.Start();
btn.Label = "关闭后台记事本";
btn.OfficeImageId = "ClearRow";
}
else
{
myProc.Kill();
btn.Label = "后台打开记事本";
btn.OfficeImageId = "NextPageOneNote";
}
hasNotepad = !hasNotepad;
}
private void button2_Click(object sender, RibbonControlEventArgs e)
{
string myTry;
myTry = this.checkBox1.Checked ? "http://www.office-cn.net" : "http://yy.com/91283328/2175343697?from=";
try
{
Process.Start(myTry);
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
private void checkBox1_Click(object sender, RibbonControlEventArgs e)
{
string lbl = checkBox1.Checked ? "打开Office中国" : " 打开YY ";
checkBox1.Label = lbl;
button2.Label = lbl;
}
}
}
复制代码
作者:
紫电
时间:
2014-3-7 23:09
[attach]53389[/attach]
西西题目有问题。
这位童鞋竟然会用3元运算符,很有前途啊。
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3