Click to See Complete Forum and Search --> : Adding multiple images to a property of an usercontrol
jozemaner
October 10th, 2009, 05:32 PM
Hi.
If anyone could help me, I would aprecciate that.
I have an imagelist control in a usercontrol I made.
I would like to create a property for this usercontrol, to select multiple images (in an 'openfiledialog'), and adding them to the imagelist inside the usercontrol.
So, what's the type of this property?
Public Property thelistofimages as [¿?]
It should be an array of images I guess. And then in the 'set' of the property it would add all the images to the imagelist. Is that posible?
Thanks!
dglienna
October 11th, 2009, 12:49 PM
Something like this?
Public Property thelistofimages as (List of(), MyImageList)
jozemaner
October 11th, 2009, 02:34 PM
Sorry, didn't get that. I'm a newbie in this stuff :P.
I can't get the code...
Public Property thelistofimages as (List of(), MyImageList)
...to work. I tried some variations, but nothing. Wrong type, too many parameters, etc.
But if I use
Public Property thelistofimages As List(of image)
In the properties panel of the usercontrol, it opens the Image Collection Editor dialog.
That's working fine, BUT, when I press add image, it says:
'Cannot create an instance of System.Drawing.Image because it is an abstract class', etc...
Any suggestions?
Thanks for the tip, I think i'm getting closer.
dglienna
October 11th, 2009, 03:10 PM
Take a look here:
http://www.java2s.com/Code/VB/Data-Structure/UseArrayListtoStoreyourownclass.htm
jozemaner
October 11th, 2009, 06:29 PM
Thanks for the answer, but I guess that's not what I need right now.
What I need is to do this:
1) Place an Usercontrol in the Mainform
2) When you click on the Usercontrol, in the PropertiesPanel, it shows a property (for example: 'Filepaths')
3) When you click the 'Filepaths' property, it shows an OpenFileDialog, so that you can select multiple files.
4) This list of FilePaths, will be the value of the 'Set' of the property 'Filepaths'
5) Then, inside the 'Set' I can divide this paths, to do whatever I like (for example: adding the files to an ImageList).
Public Partial Class UserControl1
Inherits System.Windows.Forms.UserControl
Public Sub New()
Me.InitializeComponent()
End Sub
Public Property filepaths As List(Of [i-have-no-idea])
Set(Value as List(Of [i-have-no-idea]))
For i = 0 To value.Count
imagelist1.Images.Add(value.Item(i))
Next
End Set
Get
End Get
End Property
End Class
I know this code doesn't work, its only an example :P.
Any ideas?
I did a property that lets you select an image from your pc and opens it in a picturebox inside the usercontrol, and I did a property that let you select multiple images with the images collection editor, but I can't get both to work :S.
jozemaner
October 12th, 2009, 12:05 AM
I know there's got to be a way to do this :P... but I just can't get it hehehehe.
with the code...
Private _imglst as ImageList.ImageCollection
Public Property imglst as ImageList.ImageCollection
Set (value as ImageList.ImageCollection)
'msgbox(value.Count)
End Set
Get
End Get
end property
...in the properties of the usercontrol, I have the property 'imglst' wich opens an Images Collection Editor, that lets you add images, modify their parameters, see a thumbnail, etc.
The problem is that the "msgbox(value.Count)" line gives this error:
System.InvalidOperationException:
Error:Object reference not set to an instance of an object. --->
I guess its because there is no imagelist and I'm using an imagecollection :P. But this imagecollection type is the only type that shows this Images Collection Editor (that lets you add multiple images and modify their parameters)...
Any Ideas? How can I create an instance in here?
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.