DesignMode in an inherited CustomControl 
Author Message
 DesignMode in an inherited CustomControl

Given a control:

        Class MyTreeView
                Inherits TreeView
                ...
        End Class

The DesignMode is always False. The superclass has an ISite and a
Container, so why wouldn't this ever be set to True?

In the documentation of ISite, it provides the sources for two classes
(ISBNSite & BookComponent). What it doesn't do is provide any link
between them.

If I impelement a property thus:

        Public Overrides Property Site() As ISite
                Get
                        Return m_ISite
                End Get
                Set(Value as ISite)
                        m_ISite = Value
                End Set
        End Property
        Private m_ISite as ISite

Although the Get is called, the Set is never called.

I don't want to have to check to see if a de{*filter*} is attached, but
nor do I want to implement two additional classes (ISite &
IComponent). Surely there's a better way of checking to see the
run-time/design-time status.

Any ideas on this?

Andy



Sun, 05 Jun 2005 17:43:54 GMT  
 DesignMode in an inherited CustomControl
I'm not able to reproduce this with my own subclass of TreeView. Be sure
that your override is actually calling the base member. In the sample below,
I can see that, in design mode, the treeview turns red. It is possible that
you are checking the DesignMode property too early--before the site gets
set--such as in the constructor.

Option Strict On

Public Class MyControl
    Inherits System.Windows.Forms.TreeView

    Private Sub SetBackColor()
        If Me.DesignMode Then
            Me.BackColor = System.Drawing.Color.Red
        Else
            Me.BackColor = System.Drawing.Color.Blue
        End If
    End Sub

    Public Overrides Property Site() As System.ComponentModel.ISite
        Get
            Return MyBase.Site
        End Get
        Set(ByVal Value As System.ComponentModel.ISite)
            MyBase.Site = Value
            SetBackColor()
        End Set
    End Property
End Class

I hope this helps.
John
The VB .NET Team

--
This posting is provided "AS IS" with no warranties, and confers no rights.

Quote:

> Given a control:

> Class MyTreeView
> Inherits TreeView
> ...
> End Class

> The DesignMode is always False. The superclass has an ISite and a
> Container, so why wouldn't this ever be set to True?

> In the documentation of ISite, it provides the sources for two classes
> (ISBNSite & BookComponent). What it doesn't do is provide any link
> between them.

> If I impelement a property thus:

> Public Overrides Property Site() As ISite
> Get
> Return m_ISite
> End Get
> Set(Value as ISite)
> m_ISite = Value
> End Set
> End Property
> Private m_ISite as ISite

> Although the Get is called, the Set is never called.

> I don't want to have to check to see if a de{*filter*} is attached, but
> nor do I want to implement two additional classes (ISite &
> IComponent). Surely there's a better way of checking to see the
> run-time/design-time status.

> Any ideas on this?

> Andy



Tue, 07 Jun 2005 05:05:29 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Checking for 'designmode'

2. Usercontrol DesignMode

3. DesignMode and ISite

4. how to determine form.designMode from a control on the form

5. Pictures on toolbar-buttons only visible in designmode

6. CustomControl Controls Collection

7. ?Projects run in DesignMode, but not when compiled?

8. VBscript accessing CustomControl.Properties

9. What can not be inherited? Can constructors be inherited?

10. Identifying Inherited Classes Properties and Methods seperately form inheriting classes P's and M's

11. Inherited relationship not seen

12. Converting from Acc95 Inherited headache

 

 
Powered by phpBB® Forum Software