From: Ricardo Furtado on 9 Mar 2010 16:46 i'm trying to create pictureboxs inside a picturebox but i need to determine when a user clics or uses the "mouseDown" event on each of those pictureboxs. I've tryed to use a global variable of type "picturebox", with the "withevents", and an array private withevents m_pics() as picturebox but visual basic doesn't let me create a "withevents" variable with an array. How can i solve this situation? My thanks in advanced
From: Armin Zingler on 9 Mar 2010 17:02 Am 09.03.2010 22:46, schrieb Ricardo Furtado: > i'm trying to create pictureboxs inside a picturebox but i need to determine > when a user clics or uses the "mouseDown" event on each of those pictureboxs. > I've tryed to use a global variable of type "picturebox", with the > "withevents", and an array > private withevents m_pics() as picturebox > but visual basic doesn't let me create a "withevents" variable with an array. > How can i solve this situation? Use the Addhandler keyword: Public Class Form1 Private m_pics() As PictureBox Sub AddBoxes() ReDim m_pics(9) For i = 0 To 9 m_pics(i) = New PictureBox AddHandler m_pics(i).MouseDown, AddressOf OnPicMouseDown Next End Sub Private Sub OnPicMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) End Sub End Class -- Armin
From: Ricardo Furtado on 10 Mar 2010 03:00 great !!! thanks "Armin Zingler" wrote: > Am 09.03.2010 22:46, schrieb Ricardo Furtado: > > i'm trying to create pictureboxs inside a picturebox but i need to determine > > when a user clics or uses the "mouseDown" event on each of those pictureboxs. > > I've tryed to use a global variable of type "picturebox", with the > > "withevents", and an array > > private withevents m_pics() as picturebox > > but visual basic doesn't let me create a "withevents" variable with an array. > > How can i solve this situation? > > Use the Addhandler keyword: > > Public Class Form1 > Private m_pics() As PictureBox > > Sub AddBoxes() > > ReDim m_pics(9) > > For i = 0 To 9 > m_pics(i) = New PictureBox > AddHandler m_pics(i).MouseDown, AddressOf OnPicMouseDown > Next > End Sub > > Private Sub OnPicMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) > > End Sub > > End Class > > > > -- > Armin > . >
|
Pages: 1 Prev: Where is "imports Win32"? Next: Add class in datacontext in the datacontext designer |