A detailed introduction to implementing pallet effects in C #

Source: Internet
Author: User


The development of desktop programs, often consider the status bar to implement the tray shortcut operation, the implementation of the tray program in the API era, or relatively complex, first in MSDN can see its function details,

The complex settings are then made based on the parameters they require.
In the. NET ERA, MS encapsulates these cumbersome details, and developers can easily implement the control and operation of the tray program. Now take a simple example to illustrate:
1. Adding NotifyIcon controls and ContextMenuStrip controls
2. Set its properties icon and CONTEXTMENUSTRP Properties, the Icon property simply selects a tray icon, contextmenustrip the shortcut menu for associating the first step.
3. Add the SizeChanged event program for the form to minimize the form of the Si cho tray:

   if (this. WindowState = = formwindowstate.minimized)            {this                . Hide ();        Can or may not, depending on whether the main form is hidden                this.notifyIcon.Visible = true;            }

4. Add the NotifyIcon Click Event, open the shortcut menu item, or other more complex action options, depending on your needs.

    private void Form1_sizechanged (object sender, EventArgs e)        {if (this. WindowState = = formwindowstate.minimized)            {this. Hide (); this.notifyIcon1.Visible = true;            }        } private void Notifyicon1_click (object sender, EventArgs e)        {this.contextMenuStrip1.Show (mouseposition.x, MOUSEPOSITION.Y);        }



The above is the C # Tray program content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.