Note that there are some explanatory texts on larger screens.

plurals
  1. PODefault Property for dotNet Interop Usercontrol
    text
    copied!<p>I need to set the default property of a dotNet Control used by an VB6 Application.</p> <pre><code>&lt;ComClass(myControl.ClassId, myControl.InterfaceId, myControl.EventsId)&gt; _ &lt;DefaultProperty("NewProperty")&gt; _ Public Class myControl Public Const ClassId As String = "86252de2-ca87-4468-adbe-ad7c47747759" Public Const InterfaceId As String = "c1cbf1a1-24bb-46c3-88a4-813eb4917845" Public Const EventsId As String = "954ed890-011c-4908-ab33-610159fe6eb1" Private newPropertyValue As String Public Property NewProperty() As String Get Return newPropertyValue End Get Set(ByVal value As String) newPropertyValue = value End Set End Property End Class </code></pre> <p>The DefualtProperty Attribute does not do the trick.</p> <p>I have read <a href="https://stackoverflow.com/questions/299251/exposing-the-indexer-default-property-via-com-interop">here</a> that manually setting the DispId to Zero should do the trick. But if I do this:</p> <pre><code>&lt;DispId(0)&gt; Public Property NewProperty() As String </code></pre> <p>Visual Basic kindly informs me that the DispId Zero is reserved for the DefaultProperty. Yeah. I know that. I want that. But how? </p> <p>Edit:</p> <pre><code>Default Public Property NewProperty(ByVal foo As Integer) As String </code></pre> <p>Does work as the property now shows up as the default property in VB6. But this will not solve my problem, because there is code which I can't change, which will do something like this:</p> <pre><code>aStringVariable = myUserControlInstance </code></pre> <p><a href="http://msdn.microsoft.com/en-us/library/h7bfkxc1(VS.71).aspx" rel="nofollow noreferrer">This MSDN article</a> has some information about this.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload