如題,在程序的運(yùn)行過程中我會(huì)動(dòng)態(tài)的在form中添加一些圖標(biāo),生成圖標(biāo)的時(shí)候也順便給其添加了右鍵菜單? PictureBox newpic = new PictureBox();? newpic.Name = m_dataframe.TagID;? newpic.Size = new System.Drawing.Size(48, 48);? newpic.Location = new System.Drawing.Point(posInfo[0], posInfo[1]);? newpic.Image = (Image)TheOldManCareSystem.Properties.Resources.normalState;? newpic.BackColor = Color.Transparent;? //add context menu to do some operate of the mark? newpic.ContextMenuStrip = this.markContextMenuStrip;在程序運(yùn)行過程中我右擊已經(jīng)生成的圖標(biāo),希望通過選項(xiàng)來改變圖標(biāo)使用的image我該如何在右鍵菜單的處理程序(下視函數(shù))中找到我點(diǎn)擊的圖標(biāo)呢? private void alarmStateClear_Click(object sender, EventArgs e)? {? ??? PictureBox picturebox = (PictureBox)sender;? //picturebox.Image = (Image)TheOldManCareSystem.Properties.Resources.normalState;? }上面操作sender是想當(dāng)然的寫的,錯(cuò)誤。應(yīng)該如何去獲得控件的操作權(quán)
winform中動(dòng)態(tài)創(chuàng)建控件的contextMenuStrip的使用問題
揚(yáng)帆大魚
2018-12-07 06:14:30