-
Jun 24th, 2015, 08:51 AM
#1
Thread Starter
Junior Member
how to pass values to an event and invoke them from another class ?
what i am trying to do is i am scrapping data from a website it contains an image as well as text contexts i have used simple regex to get the contents out .
now what i am trying to save those image currently i am downloading the image and saving it .
now the problem is as i save them i add the text-items to the listview from one class ,
i know how to add those images to the imagelist , my problem is setting those each images in listview from another class , when ever i add items to listview i need to draw an image inside the listview , which is done
save image code:
PHP Code:
Public Function saveimage(ByVal url As String, ByVal name As String) As String
Dim request As HttpWebRequest = TryCast(WebRequest.Create(url), HttpWebRequest)
Dim response As HttpWebResponse = TryCast(request.GetResponse(), HttpWebResponse)
Dim stream As Stream = response.GetResponseStream()
Dim ms As New MemoryStream()
Dim bw As New BinaryWriter(ms)
Dim br As New BinaryReader(stream)
bw.Write(br.ReadBytes(CInt(response.ContentLength)))
ms.Position = 0
Dim fred As Bitmap = TryCast(Bitmap.FromStream(ms), Bitmap)
Dim imagePath As String = "C:\img\" + name + ".jpeg"
fred.Save(imagePath)
Return name
End Function
PHP Code:
Private Sub ListView1_DrawSubItem(sender As Object, e As DrawListViewSubItemEventArgs) Handles ListView1.DrawSubItem
If e.SubItem.Text = imagestring Then
e.Graphics.DrawImage(ImageList1.Images(nindex), e.Bounds.X, e.Bounds.Y, e.Bounds.Height, e.Bounds.Height)
End If
End Sub
i want to invoke this event when ever an item is added , i dont know how to achive that .
is there any way to pass imagestring values and imagelist index from the function class to the form or is there any way i cant recreate a similar event in my function class and update my listview.
-
Jun 24th, 2015, 09:46 AM
#2
Re: how to pass values to an event and invoke them from another class ?
I am not sure I follow. DrawSubItem firing depends on the listview OwnerDraw property being set to true. Did you do that? The DrawSubItem event doesn't need to be invoked, it will fire automatically whenever the listview needs to draw a given subitem, so long as OwnerDraw is true.
-
Jun 24th, 2015, 10:10 AM
#3
Thread Starter
Junior Member
Re: how to pass values to an event and invoke them from another class ?
Originally Posted by kleinma
I am not sure I follow. DrawSubItem firing depends on the listview OwnerDraw property being set to true. Did you do that? The DrawSubItem event doesn't need to be invoked, it will fire automatically whenever the listview needs to draw a given subitem, so long as OwnerDraw is true.
yeah i know that ,and yes i have set the property and its working .
Attachment 127833
Code:
Private Sub ListView1_DrawColumnHeader(sender As Object, e As DrawListViewColumnHeaderEventArgs) Handles ListView1.DrawColumnHeader
e.DrawDefault = True
End Sub
what i want to do is the listview drawsubitem event works only when the the image name(imagestring) and imagelist index no(ImageList1.Images(nindex)) is provided
Code:
If e.SubItem.Text = imagestring Then
e.Graphics.DrawImage(ImageList1.Images(nindex), e.Bounds.X, e.Bounds.Y, e.Bounds.Height, e.Bounds.Height)
End If
is there some way to pass these values into the event form another class. basically m problem is that i have wriiten all the codes in a class , i just call them in my main form . i am using httpwebrequest and multithreading .to get the site source retrive data and pass that to the listview
Last edited by Priv4teByte.exe; Jun 24th, 2015 at 10:13 AM.
-
Jun 24th, 2015, 10:52 AM
#4
Re: how to pass values to an event and invoke them from another class ?
You can't pass them in from another class as part of the arguments, but if that other class is in scope for the method then the method can go get the information it needs from the other class when it wants to.
My usual boring signature: Nothing
-
Jun 24th, 2015, 07:43 PM
#5
Thread Starter
Junior Member
Re: how to pass values to an event and invoke them from another class ?
okay , but can i create custom event in my class to do the same ?
-
Jun 24th, 2015, 09:18 PM
#6
Re: how to pass values to an event and invoke them from another class ?
where do you save any thing to an imagelist? what is return name? are you trying to get a countrys flag in the lstview?
-
Jun 25th, 2015, 06:24 AM
#7
Thread Starter
Junior Member
Re: how to pass values to an event and invoke them from another class ?
am an idiot , i have done what i wanted i was using listview till now , i forgot that we had Datagridview in Visualstudio . i have a couple of links and images that i needed to display which is done now using the help of datagridview .
there is a tiny bit problem i am not most familiar with datagridview control i need to increase the height of all rows so that the image is a prefect fix .can someone tell me how can i do that ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|