Results 1 to 11 of 11

Thread: Typeof Problem

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Typeof Problem

    I tried to use the following code:

    VB Code:
    1. Dim ctrl as Control
    2.  
    3. For Each ctrl in grpInfo.Controls
    4.    If Typeof ctrl is TextBox Then
    5.       'hrmf
    6.    End If
    7. Next

    But When I get to the "hrmf" part, I don't have the ability to set/unset the Locked property of my Textbox control...

    Any ideas on why?

    Thanks,
    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  2. #2
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    I agree that I can find it at design time, but, effectively, I saw at 'members of textbox' and textbox class seems don't expose this property into its interface. So you can't do anything, directly, to change that 'disappeared property'. Perhaps there is an indirect way, some method ?.....I don't know!
    Live long and prosper (Mr. Spock)

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You still need to cast the object from the Control type to the TextBox type to see all of the members. Locked must not be visible because it probably isn't a member of the Control type.

    Also if you are using VS 2003 then you don't need to declare the ctrl interator before hand.
    VB Code:
    1. For Each ctrl As Control in grpInfo.Controls
    2.    If Typeof ctrl is TextBox Then
    3.       DirectCast(ctrl,TextBox).Locked=True
    4.    End If
    5. Next

  4. #4
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    Perfect Edneeis....you explained it better than me!
    Sometime I follow strange paths, trying to find the best english word to say something.
    Anyway the problem stay here.....a single doubt:
    You, Squirrelly, are the first one who try to modify that property at run time, for what I know, obviously.....so....(excuse me for this stupid question, but I saw many others, me too, to make the same mistake) is it possible you are trying to lock the textbox for user input? If it's so, you need to use 'readonly' property. Good job to you, dear friends.
    Live long and prosper (Mr. Spock)

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    That's fine and well. I actually did start using the "Readonly" attribute to stop people from using the textbox for input, but it changes the color of the textbox. Is there any way to keep it from doing that?

    I should figured that locked was a design-time property... With the whole "Lock Controls" option and the fact that it is under the "Design" category.

    Thanks for your help,

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  6. #6
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    Yes Squirrelly, your problem it's solved!
    You only need to change the background color of the textbox, choosing explicitly the one you desire. If you design your textbox choosing background color = white, it remains steady. It changes only if you let the default management of colours!
    Good job and welcome in the community of the men that confused locked and readonly properties. I'm the founder and actually president!
    Good job!
    Live long and prosper (Mr. Spock)

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    LOL. Thank you EVER so much! When do I get my membership card? (I sincerely hope there aren't any dues... I kinda have to get this project done before I have any spare cash to speak of)

    Thanks again guys,

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  8. #8
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    Memebership card is free for you. You are a president's friend !!!
    Live long and prosper (Mr. Spock)

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    He he. I wish that were true with a couple of the other clubs I'm a member of...

    VB-Newbs4Life

    &

    The Access 4 The UnAccessable Mind Assoc.



    Wanna Join?


    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  10. #10
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    Surely !!! Send me the coupon I have to fill
    Dear squirrelly, in this thread we have demonstrated that is possible (and better) to smile while learning. I think it's the right way to use a forum. We have to help each other (is this right english? ) and try to be friends, if possible. It happens, I think, if we are able to smile, also about our mistakes, as you and I were able to do! We have also learned, from the Edneeis ( I followed many threads in which He was involved and I know He's not a newbie like me) that early binding is a good practice. Probably I should turn Option strict to ON on my project !
    The next project I'll develop, It will be with option strict on, this is a Boy Scout Promise!
    Bye and good job (excuse my english, anyway)
    Live long and prosper (Mr. Spock)

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    Darn Right!!!

    Chao ,

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

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