Collection editor or subproperties

Discussion in 'ASP .Net Building Controls' started by CaptnKebec, Apr 29, 2005.

  1. CaptnKebec

    CaptnKebec Guest

    I created som custom controls with subproperties like...
    Buttons --|-- Button1
    |-- Button2

    I would like to put subproperties in the subproperties like this;
    Buttons --|--Button1--|--Visible
    | |-- Disabled
    |
    |--Button2--|--Visible
    |--Disbaled

    Or have a collection with a collection editor to be able to put data in
    those properties at design time.

    I've tried to refer a class in my subclass but the embeded properties
    doesn't show.
    I've found couple of examples in C# but nothing in VB.

    Here is the code for my control:
    ====================
    Option Explicit On
    Option Strict On

    Imports System
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
    Imports System.ComponentModel

    Namespace SPCControls
    Public Class ucTest
    Inherits Control
    Implements IPostBackEventHandler
    Dim _WindowTitle As String
    Dim _click As Integer

    Event btClick(ByVal ButtonNo As String)

    Public Sub RaisePostBackEvent(ByVal eventArgument As String)
    Implements IPostBackEventHandler.RaisePostBackEvent
    RaiseEvent btClick(eventArgument)
    End Sub


    Private Buttons As New SPCTypes.hdButtons
    <DefaultValue(""), Category("Custom"), _
    PersistenceMode(PersistenceMode.InnerProperty), _

    DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
    Public Property hdButtons() As SPCTypes.hdButtons
    Get
    Return Buttons
    End Get
    Set(ByVal Value As SPCTypes.hdButtons)
    Buttons = Value
    End Set
    End Property


    Property WindowTitle() As String
    Get
    Return _WindowTitle
    End Get
    Set(ByVal Value As String)
    _WindowTitle = Value
    End Set
    End Property



    Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
    writer.Write(("<LINK REL=""stylesheet"" TYPE=""text/css""
    HREF=""SPCStyles.css"">") & vbCr)

    writer.Write(("<TABLE id=""Table1"" style=""PADDING-RIGHT: 0px;
    PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; CLIP: rect(auto auto
    auto auto); BORDER-TOP-STYLE: none; PADDING-TOP: 0px; BORDER-RIGHT-STYLE:
    none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none""") & vbCr)
    writer.Write((" height=""63"" cellSpacing=""0""
    cellPadding=""0"" width=""100%"" align=""left"" border=""0"">") & vbCr)
    writer.Write((" <TR>") & vbCr)
    writer.Write((" <TD vAlign=""bottom"" align=""left""
    width=""90%"" background=""./images/header/bar_top.png"">&nbsp; <IMG
    onClick=""jscript:" & Page.GetPostBackEventReference(Me, "Back") & """
    id=""IMG1""") & vbCr)
    writer.Write((" class=""bt1_n""
    onmouseover=""this.className='bt1_h'""
    onmouseout=""this.className='bt1_n'""") & vbCr)

    writer.Write((" src=""./images/bar_buttons/empty.gif"">&nbsp;") & vbCr)
    writer.Write((" </TD>") & vbCr)
    writer.Write((" <TD align=""right"" width=""90%""
    background=""./images/header/bar_top.png""></TD>") & vbCr)
    writer.Write((" <TD align=""right""><IMG alt=""""
    src=""./images/header/bar_log.png""></TD>") & vbCr)
    writer.Write((" </TR>") & vbCr)
    writer.Write((" </TABLE>") & vbCr)

    End Sub



    End Class
    End Namespace

    ******************************************
    And here is the code for the class
    ======================
    Imports System.ComponentModel
    Namespace SPCTypes
    <TypeConverter(GetType(ExpandableObjectConverter))> _
    Public Class hdButtons
    Private strButton1 As hdButton
    Private strButton2 As hdButton

    <DefaultValue(""), NotifyParentProperty(True),
    RefreshProperties(RefreshProperties.Repaint)> _
    Property [Button1]() As hdButton
    Get
    Return strButton1
    End Get
    Set(ByVal Value As hdButton)
    strButton1 = Value
    End Set
    End Property
    <DefaultValue(""), NotifyParentProperty(True),
    RefreshProperties(RefreshProperties.Repaint)> _
    Property [Button2]() As hdButton
    Get
    Return strButton2
    End Get
    Set(ByVal Value As hdButton)
    strButton2 = Value
    End Set
    End Property
    End Class
    <TypeConverter(GetType(ExpandableObjectConverter))> _
    Public Class hdButton
    Private strVisible As String = ""
    Private strPicture As String = ""

    <DefaultValue(""), NotifyParentProperty(True),
    RefreshProperties(RefreshProperties.Repaint)> _
    Property [Visible]() As String
    Get
    Return strVisible
    End Get
    Set(ByVal Value As String)
    strVisible = Value
    End Set
    End Property
    <DefaultValue(""), NotifyParentProperty(True),
    RefreshProperties(RefreshProperties.Repaint)> _
    Property [Picture]() As String
    Get
    Return strPicture
    End Get
    Set(ByVal Value As String)
    strPicture = Value
    End Set
    End Property
    End Class

    End Namespace
    CaptnKebec, Apr 29, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stylus Studio
    Replies:
    0
    Views:
    635
    Stylus Studio
    Aug 3, 2004
  2. Øyvind Isaksen
    Replies:
    1
    Views:
    946
    Øyvind Isaksen
    May 18, 2007
  3. Justin Friel

    Subproperties

    Justin Friel, Apr 1, 2006, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    105
    Teemu Keiski
    Apr 2, 2006
  4. Replies:
    1
    Views:
    274
    Tim Dot NoSpam
    May 19, 2006
  5. Jason

    DataBinding to SubProperties

    Jason, Jun 21, 2006, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    133
    Walter Wang [MSFT]
    Jun 27, 2006
Loading...

Share This Page