Design-Time Properties in an OCX

Posted on 1998-07-24
Last Modified: 2010-05-03
I have an OCX made from a 'TextBox' control provided with VB.  

I recently wanted to add an alignment property to this control.  

The problem that I am encountering is that when I go to compile, VB says, "Can't Assign to Read-Only Property" because, to the embedded TextBox control, it _is_ runtime, even though, to the OCX it is design time.

The actual statement is this:

Public Property Let Alignment(A As AlignmentConstants)
    Text1.Alignment = A
End Property

The compile stops cold, with "Alignment" highlighted.

The question is:  How do you alter run-time, read-only properties in component controls of an OCX?

Question by:percosolator
  • 3
  • 2

Accepted Solution

kamall earned 100 total points
ID: 1466623
    You can not alter run-time read-only properties of a VB control embeded into your ActiveX control even though you are using your OCX in the design environment.
    The solution is either to use another control that enables setting the alignment property at run-time, or you manipulate the text alignment in the text box using your own code, which is a little bit complicated.

Hope that helps.

Author Comment

ID: 1466624
I found someone elses solution about using multiple text boxes, not an elegant solution, but I'll use it if I can't find an alternative.

Are you (or is anyone) aware of an API that might help?

Expert Comment

ID: 1466625
>> Are you (or is anyone) aware of an API that might help?

Unfortunately, NO. I have no idea on how to do this using API.

Author Comment

ID: 1466626

I was looking around and saw that "C" I gave you.  Sorry about that, doesn't appear to be any way around this issue.  

I will give you a better one next time, k? Got a couple lurking about that I have been tempted to post, but I always love a good challenge.


Expert Comment

ID: 1466627
Thank you for your comment, and don't worry about the 'C' grade.
I am here to help you and the other people.
Have a nice day.

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now