Results 1 to 5 of 5

Thread: Disable Property in Custom Control

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2002
    Posts
    142

    Disable Property in Custom Control

    I have two properties in a custom control, SizeLimit(boolean) and SizeLimitSize(integer).

    I need to know how to disable the property SizeLimitSize if SizeLimit is False and Activate it if SizeLimit=true.

    Thanks,
    Bebandit

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    You can't disable it, but you can control wether the value is accepted.

    Something like this:
    VB Code:
    1. Public Property SizeLimitSize As Integer
    2.     Get
    3.         Return MySizeLimitSize
    4.     End Get
    5.     Set (Value as Integer)
    6.         If SizeLimit=True Then
    7.             MySizeLimit=Value
    8.         Else
    9.             Throw New Exception("Value can only be set if SizeLimit is True.")
    10.         End If
    11.     End Set
    12. End Property
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2002
    Posts
    142

    Thanks!!

    That is what I was looking for....
    I am not sure how you would gray it out all together but this should work great. Thanks!!!

  4. #4
    Junior Member
    Join Date
    May 2004
    Posts
    27
    could i use the above example to validate my text boxes on my programe? so that users can only enter text and not numbres in certain boxes.

    Thanks

    Homer

  5. #5
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Originally posted by Homer S
    could i use the above example to validate my text boxes on my programe? so that users can only enter text and not numbres in certain boxes.

    Thanks

    Homer
    Not unless you inherit from the textbox, and override the Text property.

    The above example was designed to be used within usercontrols.

    Sorry...
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

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