Results 1 to 8 of 8

Thread: Delete Image property during design time of usercontrol

  1. #1

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    58

    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.

  2. #2
    Junior Member
    Join Date
    Sep 2003
    Posts
    26
    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?

  3. #3

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    58

    Thumbs down

    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.

  4. #4

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    58
    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.

  5. #5
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    post your public Image property code.

  6. #6
    Junior Member
    Join Date
    Sep 2003
    Posts
    26
    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.

  7. #7

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    58
    Its just a Hello World user control. I created a new project of UserControl type. Then I put these codes:

    VB Code:
    1. Public Class UserControl1
    2.     Inherits System.Windows.Forms.UserControl
    3.  
    4. #Region " Windows Form Designer generated code "
    5. '....
    6. #End Region
    7.  
    8.     Private mImage As Image
    9.  
    10.     Public Property MyImage() As Image
    11.         Get
    12.             Return mImage
    13.         End Get
    14.         Set(ByVal Value As Image)
    15.             mImage = Value
    16.         End Set
    17.     End Property
    18. 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.

  8. #8

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    58
    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
  •  



Click Here to Expand Forum to Full Width