|
-
Nov 13th, 2003, 02:33 AM
#1
Thread Starter
Member
Delete Image property during design time of usercontrol
Hi seniors,
I am creating a user control which exposes an Image property. During design time, it allows the user to select an Image file(bmp, jpg, ico, etc). However, once its selected, the user cant delete it. The common way that applies to 'most' controls, select the whole entry of the property and press Delete button doesn't work.
Anyone has a clue????
Thanks.
-
Nov 13th, 2003, 04:50 AM
#2
Junior Member
can you allow them to either click on a button which will clear it out, or set some other method up which will call the method that is used to allow them to make the selection in the first place?
-
Nov 13th, 2003, 05:19 AM
#3
Thread Starter
Member
The problem is during design time. The user can set image to this Image property as how we set image to form's BackgroundImage property.
Click on a button (...) then select the image file. And we can delete the image assigned to form's BackgroundImage property just by selecting the whole entry (something like System.Drawing.Bitmap) and press Delete will set it to (none).
However, the same way doesn't apply to my usercontrol. Select the whole entry and pressed Delete, the image is still attached.
-
Nov 13th, 2003, 05:24 AM
#4
Thread Starter
Member
I am so sorry about the thumbdown icon on the previous message, i dont know how it gets there. I really appreciate any reply and ur effort to help me.
-
Nov 13th, 2003, 11:55 AM
#5
I wonder how many charact
post your public Image property code.
-
Nov 13th, 2003, 12:27 PM
#6
Junior Member
picturebox.image = image.fromfile("C:\picture.jpg")
something like that can change it. so if you use some method to get what you want the next picture or extention to be, you can change it that way.
But it would be helpful to post the code or to clarify a little better on what exactly you're trying to do, when things will be changed, etc.
-
Nov 13th, 2003, 05:24 PM
#7
Thread Starter
Member
Its just a Hello World user control. I created a new project of UserControl type. Then I put these codes:
VB Code:
Public Class UserControl1
Inherits System.Windows.Forms.UserControl
#Region " Windows Form Designer generated code "
'....
#End Region
Private mImage As Image
Public Property MyImage() As Image
Get
Return mImage
End Get
Set(ByVal Value As Image)
mImage = Value
End Set
End Property
End Class
During the design time, it shows the property named MyImage but once an image is attached, it cant be deleted. I tried by pressing BACKSPACE but to no avail.
Thanks.
-
Nov 13th, 2003, 06:43 PM
#8
Thread Starter
Member
Hi,
I have found the solution. Use DefaultValueAttribute before the property declaration.
<System.ComponentModel.DefaultValue(GetType(Image), "Nothing")> _
Public property MyImage as Image
.....
End Property
Thanks guys.
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
|