What does "I don't really have access to this" mean?
If you want the Get of the DataField property to return the form's
Text property, I would try:
Get
Dim frm As System.Windows.Forms.Form = Me.FindForm()
Return If(frm Is Nothing, '', frm.Text)
End Get
On Tue, 9 Jun 2009 18:52:05 -0700, "Derek Hart" <(E-Mail Removed)>
wrote:
>Jack,
>
>I have a class that just inherits a control. Just for testing, I placed the
>CType down below. This class is not part of a usercontrol directly. It is
>just a textbox that is used inside the IDE toolbox. In the "Get" part of the
>property I tried looking at the parent, but I don't really have access to
>this. Do you know how that might look?
>
><ToolboxBitmapAttribute(GetType(TextBox))> _
>
>Public Class MyTextBox
>
> Inherits TextBox
>
> Private _DataField As String = ""
>
>
>
>
>
> <CategoryAttribute("Design"), _
>
> DefaultValueAttribute(GetType(String), ""), _
>
> DescriptionAttribute("Name of the data field."), _
>
> Editor(GetType(MergeFieldNameBuilder),
>GetType(System.Drawing.Design.UITypeEditor))> _
>
> Public Property DataField() As String
>
> Get
>
> Return CType(Site.Container.Components(0),
>System.Windows.Forms.Form).Text
> End Get
>
> Set(ByVal value As String)
>
> _DataField = value
>
> End Set
>
> End Property
>
>End Class
>
>
>
>Derek
>
>
>"Jack Jackson" <jjackson-(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> It looks like that would work.
>>
>> I still don't see why you don't just use (in some method in your
>> UserControl) Me.FindForm() or use Me.Parent to back up through the
>> parents of your UserControl until you get to the form.
>>
>> Even in the IDE, each control is added to its parent's Controls
>> collection, so starting with any control you can look through the tree
>> of all controls.
>>
>> On Mon, 8 Jun 2009 10:13:27 -0700, "Derek Hart" <(E-Mail Removed)>
>> wrote:
>>
>>>I think I have found something that puts me on the right track. This will
>>>give me the name of the form inside the property:
>>>
>>>Return Site.Container.Components(0).Site.Name
>>>
>>>I can even get to the properties with correct casting.
>>>
>>>Return CType(Site.Container.Components(0), System.Windows.Forms.Form).Text
>>>
>>>Any comments on if this is the best way to get to properties at design
>>>time?
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>"Derek Hart" <(E-Mail Removed)> wrote in message
>>>news:(E-Mail Removed)...
>>>> I'm just not sure where to do this... the user control is self
>>>> contained... how can I talk to the live form at design time? For
>>>> example,
>>>> here is the property I am modifying on an inherited TextBox: I need to
>>>> pass the name of the form at design time so the custom UITypeEditor has
>>>> the name to get the correct data to return to the UITypeEditor in the
>>>> property.
>>>>
>>>> <CategoryAttribute("Design"), _
>>>> DefaultValueAttribute(GetType(String), ""), _
>>>> DescriptionAttribute("Name of the data field."), _
>>>> Editor(GetType(MergeFieldNameBuilder),
>>>> GetType(System.Drawing.Design.UITypeEditor))> _
>>>> Public Property DataField() As String
>>>> Get
>>>> Return _DataField
>>>> End Get
>>>> Set(ByVal value As String)
>>>> _DataField = value
>>>> End Set
>>>> End Property
>>>>
>>>>
>>>> "Jack Jackson" <jjackson-(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> On Sun, 7 Jun 2009 17:37:59 -0700, "Derek Hart" <(E-Mail Removed)>
>>>>> wrote:
>>>>>
>>>>>>Build a usercontrol that I want developers to use in Visual Studio. I
>>>>>>need
>>>>>>to pass some variables into the control at design time, so the property
>>>>>>grid
>>>>>>can pop up with specific properties. How could I pass, for example, the
>>>>>>name
>>>>>>of the form I am on (at design time), to the property?
>>>>>>
>>>>>
>>>>> Why don't you just back up through the Parent properties until you get
>>>>> to the form?
>>>>
>>>>
>>>
>
|