Results 1 to 6 of 6

Thread: Setting Read-Only Values at Design Time

  1. #1

    Thread Starter
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444

    Question Setting Read-Only Values at Design Time

    I have a textbox on a user control and I want to let the user set the MultiLine and Scrollbars properties at Design time, but I get an error about them being a read-only property. Is there any way I can over come this?

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    SOME properties can be changed through heavy subclassing, but it's a pain in the butt. It'd probaby be easier in your situation to have to have 2 actual textboxes one with those settings set and one without then just switch the active one when the user wants. You can minimize the mess of code by making a textbox in code and just setting the active one to it so you only have to deal with the same on in code all the time.

    Lets say you have to actual textbox controls on the form both with visible=false. We'll call one txtMulti and the other txtSingle-on second thought I'll attach a sample.

  3. #3

    Thread Starter
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Thanks for the idea. I would have thought there was a simple API call to do what I want though.

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Well the problem is that most of those those readonly properties are readonly because they can only be set when the window is created. So to overcome thise you end up recreating the window and all hell breaks lose from there.

  5. #5

    Thread Starter
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Oh I see. It seems a waste of resources thought to have to use 2 text boxes. But you can change the multiline property in the IDE of VB, so does that mean there must be some way to do?

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Well the problem reside in the fact that it is runtime and the control/window has already been created (when the control was loaded). So you'd have destroy and recreate the window of the control (basically the control itself) to change some properties. It would almost be simple if you could dim a new textbox and set it's properties but you'd have to load it to change the properties and when you do it just uses the defaults and creates teh window so you'd be back to square one. You could rummage through the C++ header for the class that makes the textbox and see if you find any way you could send a message or something and change it.

    Althouhg IMHO the resource of 2 textboxes is less than the work to try and change the readonly properties (IF these properties can be changed via some other way).

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