单击更改图标通知(Change Icon Notify on Click)

   IT问题网   2021-01-18 00:00:00

问 题

是否可以点击更换器notifyicon1?该程序在c#中写入

解决方案

是的。

只需通过notifyicon.icon property[ ^ ]

继续第一个回答,此示例 [ ^ ](虽然在vb.net中)应该可以帮到你。



使用notifyicon应用程序托盘图标显示进度 [ ^ ]也应该帮助你。

使用system;

使用system.drawing;

使用system.windows.forms;



公共类form1:system.windows.forms.form

{

private system.windows.forms.notifyicon notifyicon1;

private system。 windows.forms.contextmenu contextmenu1;

private system.windows.forms.menuitem menuitem1;

private system.componentmodel.icontainer组件;



[stathread]

static void main()

{

application.run(new form1());

}



public form1()

{

this.components = new system.componentmodel.container();

this.contextmenu1 = new system.windows.forms.contextmenu();

this.menuitem1 = new system.windows.forms .menuitem();



//初始化contextmenu1

this.contextmenu1.menuitems .addrange(

new system.windows.forms.menuitem [] {this.menuitem1});



//初始化menuitem1

this.menuitem1.index = 0;

this.menuitem1.text ="exit";

this.menuitem1.click + = new system。 eventhandler(this.menuitem1_click);



//设置表单的显示方式。

this.clientsize = new system.drawing .size(292,266);

this.text ="通知图标示例";



//创建notifyicon。

this.notifyicon1 = new system.windows.forms.notifyicon(this.components);



// icon属性设置图标在这个应用程序的系统托盘中出现

//

notifyicon1.icon = new icon("appicon.ico");



// contextmenu属性设置菜单

// app右键单击系统托盘图标时听到。

notifyicon1.contextmenu = this.contextmenu1;



// text属性设置文本当鼠标悬停在系统托盘图标上时,将显示工具提示中的
//

notifyicon1.text ="form1(notifyicon示例)";

notifyicon1.visible = true;



//处理doubleclick事件以激活表单。

notifyicon1.doubleclick + = new system.eventhandler(this.notifyicon1_doubleclick);



}



protected override void dispose(bool处理)

{

//清理正在使用的任何组件。

if(处理)

if(b) components!= null)

components.dispose();



base.dispose(disposing);

}



private void notifyicon1_doubleclick(object sender,eventargs e)

{

//当用户双击通知图标时显示表单。



//如果窗体最小化,则将windowstate设置为正常。

if(this.windowstate == formwindowstate.minimized)

this.windowstate = formwindowstate.normal;



//激活表格。

this.activate();

}



private void menuitem1_click(object sender,eventargs e){

//关闭表单,关闭应用程序。

this.close();

}

}

标签:单击更改图标通知



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

如果用户已经登录,则在同一浏览器中重定向到主页asp .net c#(Redirect to Home page if user already logged in, in same browser asp .net c#)

problem i want to make application that if user in logged ...

需要帮助来使用MySqlTransaction(Need help in using MySqlTransaction)

problem hi all i would like to use mysqltransaction in my ...

如何使用VBscript导航Windows注册表树(How to navigate Windows registry tree with VBscript)

problem does anyone know how to go about navigating the w ...

silverlight内存泄漏(silverlight memory leak)

problem hi, i was creating a dependencyproperty changed w ...

如何在json中获取单个元素(How to get single element in json)

problem in wcf service i am getting json response in that ...

双击文件打开程序,如何在c#中实现(double click on file opens program, how to implement in c#)

problem usually when a program in installed, you can clic ...

如何在我添加的现有数据表中添加新列,但它是bofore行的结尾(how add new column in existing datatable i added but its is come end of the bofore rows)

problem my datatable contans two columns id value ----- ...

如何在c#.net中的现有页面中打开新网址(How to open new url in existing page in c#.net)

problem hi to all, this is mdsiddiqali.i added new page n ...

DeleteObject方法不会删除任何内容 - 请帮忙。(DeleteObject method doesn't delete anything - please help.)

problem hello. i am trying to create method that will del ...

项目模板类型在C#中使用?(PROJECT TEMPLATE TYPE TO USE IN C#)

problem edit; okay i am creating a dock for programs to r ...

如何在我添加的现有数据表中添加新列,但它是bofore行的结尾(how add new column in existing datatable i added but its is come end of the bofore rows)

problem my datatable contans two columns ; id value ---- ...

在c#和asp.net中使用LinkedIn API?(Working with LinkedIn APIs in c# and asp.net )

problem hey i was trying to design an asp.net based webs ...

设计模式的案例研究(Case Studies for Design Pattern)

problem hi everyone, though i found "design patterns exp ...

返回所有组件(Retur all components)

problem dears, i need a method to return all named contro ...

Picturebox控件不会触发鼠标事件(Picturebox control not firing mouse events)

problem i have a picturebox control in a groupbox control ...

Windows 7中的VB.net + Crystall报告问题(VB.net + Crystall report issue in Windows 7)

problem i have created windows application in vb.net 2005 ...

如何将数据表中的数据保存回数据库?(How to save the data in a datatable back into the database)

problem i have filled my datatable with my sqladapter ass ...

测试ip和developpe ip扫描仪(Test ip and developpe ip scanner)

problem hi friends, i want help !!! i need c ...

在.Net中使用WCF的3层(3 tier using WCF in .Net)

problem hi, i have developed a 3 tier application in vb. ...

连续循环不循环(Continual Loop Not Looping)

problem j have code that is suppose to continue looping l ...