日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

Winform中实现仿XP系统的任务栏菜单效果(附代码下载)

發(fā)布時間:2025/3/19 windows 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Winform中实现仿XP系统的任务栏菜单效果(附代码下载) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

場景

效果

?

注:

博客主頁:
https://blog.csdn.net/badao_liumang_qizhi
關注公眾號
霸道的程序猿
獲取編程相關電子書、教程推送與免費下載。

實現(xiàn)

新建一個Form窗體,設計頁面布局如下

?

折疊效果的向上和向下按鈕是PictureBox,從上往下依次的Tag標簽為1,2,3

三個PictureBox都綁定同一個點擊事件,在點擊事件中根據(jù)傳遞的Tag標簽的值在Switch-case中進行處理。

在Switch-case中分別將對應的一組PictureBox和Panel對象賦值給上面聲明的靜態(tài)的兩個控件對象。

下面要隱藏的Panel對象的tag屬性默認為0,在上面switch-case中獲取一組對應的控件對象后進行判斷,

如果Tag為0或者2則是將Panel隱藏,同時將Tag標簽設置為1,表示隱藏。

如果是1,則表示已經(jīng)處于隱藏狀態(tài),則會將其顯示并將Tag設置為2。

關鍵代碼

?private static Panel Var_Panel = new Panel();private static PictureBox Var_Pict = new PictureBox();private static int Var_i = 0;private Font Var_Font = new Font("宋體", 9);private void pictureBox_1_Click(object sender, EventArgs e){Var_i = Convert.ToInt16(((PictureBox)sender).Tag.ToString());switch (Var_i){case 1:{Var_Panel = panel_Gut_1;Var_Pict = pictureBox_1;break;}case 2:{Var_Panel = panel_Gut_2;Var_Pict = pictureBox_2;break;}case 3:{Var_Panel = panel_Gut_3;Var_Pict = pictureBox_3;break;}}if (Convert.ToInt16(Var_Panel.Tag.ToString()) == 0 || Convert.ToInt16(Var_Panel.Tag.ToString()) == 2){Var_Panel.Tag = 1;//隱藏標識Var_Pict.Image = null;Var_Pict.Image = Properties.Resources.朝下按鈕;Var_Panel.Visible = false;}else{if (Convert.ToInt16(Var_Panel.Tag.ToString()) == 1){Var_Panel.Tag = 2;//顯示標識Var_Pict.Image = null;Var_Pict.Image = Properties.Resources.朝上按鈕;Var_Panel.Visible = true;}}}private void Form1_Load(object sender, EventArgs e){pictureBox_1.Image = null;pictureBox_1.Image = Properties.Resources.朝上按鈕;pictureBox_2.Image = null;pictureBox_2.Image = Properties.Resources.朝上按鈕;pictureBox_3.Image = null;pictureBox_3.Image = Properties.Resources.朝上按鈕;Var_Font = label_1.Font;}private void label_1_MouseEnter(object sender, EventArgs e){((Label)sender).ForeColor = Color.Gray;((Label)sender).Font = new Font(Var_Font, Var_Font.Style | FontStyle.Underline);}private void label_1_MouseLeave(object sender, EventArgs e){((Label)sender).ForeColor = Color.Black;((Label)sender).Font = new Font(Var_Font, Var_Font.Style);}

代碼下載

https://download.csdn.net/download/BADAO_LIUMANG_QIZHI/12025648

總結(jié)

以上是生活随笔為你收集整理的Winform中实现仿XP系统的任务栏菜单效果(附代码下载)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。