Microsoft KB Archive/172056: Difference between revisions
(importing KB archive) |
m (Text replacement - """ to """) |
||
Line 92: | Line 92: | ||
<li>From the Tools Menu, select Procedure Attributes.</li> | <li>From the Tools Menu, select Procedure Attributes.</li> | ||
<li>In the Procedure Attributes dialog Window, click the Advanced button.</li> | <li>In the Procedure Attributes dialog Window, click the Advanced button.</li> | ||
<li>In the Data Binding section, check | <li>In the Data Binding section, check "Property is databound" and "This property binds to DataField." Click OK.</li> | ||
<li>Close the UserControl designer and code window.</li> | <li>Close the UserControl designer and code window.</li> | ||
<li>Add a Data control to Form1.</li> | <li>Add a Data control to Form1.</li> | ||
<li><p>Set the following properties of the Data control:</p> | <li><p>Set the following properties of the Data control:</p> | ||
<pre class="codesample"> DatabaseName = | <pre class="codesample"> DatabaseName ="C:\Program Files\Microsoft Visual Basic\Biblio.mdb" | ||
DefaultCursorType = 0 | DefaultCursorType = 0 | ||
DefaultType = 2 | DefaultType = 2 | ||
ReadOnly = False | ReadOnly = False | ||
RecordsetType = 1 | RecordsetType = 1 | ||
RecordSource = | RecordSource = "Authors" | ||
</pre></li> | </pre></li> | ||
<li>Add an instance of UserControl1 to the form.</li> | <li>Add an instance of UserControl1 to the form.</li> | ||
<li><p>Change the following properties of UserControl11.</p> | <li><p>Change the following properties of UserControl11.</p> | ||
<pre class="codesample"> DataField= | <pre class="codesample"> DataField= "Author" | ||
DataSource= | DataSource= "Data1" | ||
</pre></li> | </pre></li> | ||
<li>Run the application by pressing the F5 key.</li> | <li>Run the application by pressing the F5 key.</li> | ||
<li>Move through the authors in Biblio using the Data control (just to verify that everything works in the IDE).</li> | <li>Move through the authors in Biblio using the Data control (just to verify that everything works in the IDE).</li> | ||
<li>Compile to EXE.</li> | <li>Compile to EXE.</li> | ||
<li>Run the EXE. Note that the | <li>Run the EXE. Note that the "bound" property of the UserControl does not change as it did in the IDE.</li></ol> | ||
Latest revision as of 11:06, 21 July 2020
Article ID: 172056
Article Last Modified on 11/18/2003
APPLIES TO
- Microsoft Visual Basic 5.0 Control Creation Edition
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
This article was previously published under Q172056
SYMPTOMS
A UserControl created within a Standard EXE as a private object will not correctly bind its defined bound properties after the application is compiled to an EXE. While the application is debugged in the Visual Basic 5.0 IDE, the control and its binding function correctly.
CAUSE
RESOLUTION
The only workaround is to compile a separate binary for the OCX to be a public control. In this fashion, the bindable public properties function correctly.
To hide the use of this control adequately from other applications (one of the main benefits of a private UserControl) the author should add run-time licensing support to minimize the use of the control outside the intended application.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
Steps to Reproduce
- Create a new Standard EXE project.
- Add a private UserControl (UserControl1) to the project.
- Add a label (Label1) to the UserControl.
Add the following code to the UserControl:
Public Property Get Value() As Variant Value = Label1.Caption End Property Public Property Let Value(ByVal vNewValue As Variant) Label1.Caption = vNewValue End Property
- From the Tools Menu, select Procedure Attributes.
- In the Procedure Attributes dialog Window, click the Advanced button.
- In the Data Binding section, check "Property is databound" and "This property binds to DataField." Click OK.
- Close the UserControl designer and code window.
- Add a Data control to Form1.
Set the following properties of the Data control:
DatabaseName ="C:\Program Files\Microsoft Visual Basic\Biblio.mdb" DefaultCursorType = 0 DefaultType = 2 ReadOnly = False RecordsetType = 1 RecordSource = "Authors"
- Add an instance of UserControl1 to the form.
Change the following properties of UserControl11.
DataField= "Author" DataSource= "Data1"
- Run the application by pressing the F5 key.
- Move through the authors in Biblio using the Data control (just to verify that everything works in the IDE).
- Compile to EXE.
- Run the EXE. Note that the "bound" property of the UserControl does not change as it did in the IDE.
REFERENCES
For more information about licensing processes, see the Microsoft Visual Basic Books Online:
Component Tools Guide Creating ActiveX Components Building ActiveX Controls Distributing Controls
Keywords: kbbug KB172056