EDN Admin
Well-known member
hey there, while searching for something on google, I found an interesting http://social.msdn.microsoft.com/Forums/en-us/Vsexpressvb/thread/66e70978-353b-4ca6-82fb-42c1e35981b0" target="_blank
thread (here at msdn) on which bdbodger MCC told something related to custom tags.
He stated that we can create a structure, in order to enhance a tag, but I dont realize how we get specific information from it...
His code in vb:
<pre class="prettyprint lang-vb" style=" Public Class Form1
Public Structure PictureBoxInfo
Dim volume As Integer
Dim imagefile As String
End Structure
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each c As Control In Me.Controls
If TypeOf c Is PictureBox Then
Dim NewInfo As PictureBoxInfo
NewInfo.volume = 0
NewInfo.imagefile = "0.png"
CType(c, PictureBox).Image = Image.FromFile("c:myimageso.png")
AddHandler c.MouseClick, AddressOf PictureBoxes_MouseClick
End If
Next
End Sub
Private Sub PictureBoxes_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Dim PicInfo As PictureBoxInfo = sender.tag
If e.Button = Windows.Forms.MouseButtons.Left Then
PicInfo.volume += 1
ElseIf e.Button = Windows.Forms.MouseButtons.Right Then
PicInfo.volume -= 1
End If
sender.tag = PicInfo
code to set image
End Sub
End Class [/code]
<br/>
As you can see, the first line inside Mouse Click event is assigning a PictureBoxInfo with senders tag. I dont understand which value it is supposed to get from the tag, since its not assigned yet(I think)
Furthermore, he stores back the Tag, after changing volumes value.
Can someone explain me how does this thing really work? I think Im missing something relevant, but I really dont get it.
Cant we do that in C#?
Thanks
<br/>
View the full article
thread (here at msdn) on which bdbodger MCC told something related to custom tags.
He stated that we can create a structure, in order to enhance a tag, but I dont realize how we get specific information from it...
His code in vb:
<pre class="prettyprint lang-vb" style=" Public Class Form1
Public Structure PictureBoxInfo
Dim volume As Integer
Dim imagefile As String
End Structure
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each c As Control In Me.Controls
If TypeOf c Is PictureBox Then
Dim NewInfo As PictureBoxInfo
NewInfo.volume = 0
NewInfo.imagefile = "0.png"
CType(c, PictureBox).Image = Image.FromFile("c:myimageso.png")
AddHandler c.MouseClick, AddressOf PictureBoxes_MouseClick
End If
Next
End Sub
Private Sub PictureBoxes_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Dim PicInfo As PictureBoxInfo = sender.tag
If e.Button = Windows.Forms.MouseButtons.Left Then
PicInfo.volume += 1
ElseIf e.Button = Windows.Forms.MouseButtons.Right Then
PicInfo.volume -= 1
End If
sender.tag = PicInfo
code to set image
End Sub
End Class [/code]
<br/>
As you can see, the first line inside Mouse Click event is assigning a PictureBoxInfo with senders tag. I dont understand which value it is supposed to get from the tag, since its not assigned yet(I think)
Furthermore, he stores back the Tag, after changing volumes value.
Can someone explain me how does this thing really work? I think Im missing something relevant, but I really dont get it.
Cant we do that in C#?
Thanks
<br/>
View the full article