Results 1 to 3 of 3

Thread: Repaint/Rerender Control in IDE

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Repaint/Rerender Control in IDE

    I have a custom phone control consisting of 3 textboxes.
    Two of the textboxes are created in the constructor and the third textbox is optional, depending on whether the developer wants the control to handle international numbers.
    There is a boolean property (ShowCountryCode), which determines whether the country code textbox will be displayed.

    The problem I am having with this is when the control is placed on the form it shows the two default textboxes, the ShowCountryCode property is set to False by default, but if the developer sets the ShowCountryCode property to True. I want the control to re-render/repaint itself in the IDE to show three textboxes instead of the default two.
    It renders just fine at run-time, but not in design time in the IDE.

    Anyone know how to repaint/re-render a control in the IDE, based on a properties setting???
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Seems to me the answer lies in the IDesigner you attach to the class...

    The IDesigner is ultimately what is responsible for the look of the control at design time.

    Really, all you do is override the DesignTimeHTML, and for your purpose, you would check the Designer's property and if it was 3 textboxes, you would append another input into the html.
    http://msdn.microsoft.com/library/de...gnersample.asp


    http://msdn.microsoft.com/library/de...orwebforms.asp
    Last edited by nemaroller; May 13th, 2004 at 05:41 PM.

  3. #3
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Here's a sample from my own DateTime picker control... now I only do something really simple which is get the width... but you're supposed to use .IsItemDirty or something.. but I never bothered to learn that much
    VB Code:
    1. <DefaultProperty("Text"), DesignerAttribute(GetType(CESICalendarDesigner), GetType(IDesigner)), ToolboxData(" <{0}:CESIDateTimePicker runat=server></{0}:CESIDateTimePicker>")> _
    2.  Public Class CESIDateTimePicker
    3. .....
    4. End Class
    5.  
    6.  
    7. ''''''Here is the designer class that you make an instance of your
    8. '''''class declared above, and mess with its properties. I delcared this following class in the same .vb file after End Class of my control above.
    9. ''''notice how I convert the designer's component property into my control, and access its current Width.
    10.  Public Class CESICalendarDesigner
    11.     Inherits System.Web.UI.Design.ControlDesigner
    12.     Private myDT As CESIDateTimePicker
    13.  
    14.  
    15.     Public Overrides Function GetDesignTimeHtml() As String
    16.  
    17.         Dim r As CESIDateTimePicker = CType(Me.Component, CESIDateTimePicker)
    18.  
    19.         Dim s1 As String = "<table bgcolor=#FFFFFF height=5px border=1 cellpadding=0 cellspacing=0 width="
    20.         Dim s2 As String = "><tr><td>&nbsp;</td></tr></table>"
    21.         s1 = String.Concat(s1, r.Width.ToString)
    22.         Return String.Concat(s1, s2)
    23.  
    24.  
    25.     End Function
    26.  
    27.     Public Overrides Sub Initialize(ByVal component As System.ComponentModel.IComponent)
    28.  
    29.         myDT = DirectCast(component, CESIDateTimePicker)
    30.         MyBase.Initialize(component)
    31.     End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width