Custom control renders table but doesn't resize at design time.

Discussion in 'ASP .Net Building Controls' started by Chubby Arse, Oct 6, 2005.

  1. Chubby Arse

    Chubby Arse Guest

    Hi all,

    I have a control, that basically is my own version of the datagrid,
    except that is renderers purely readonly tabular information.

    When the control is rendered to the designer, I can click on the
    control as rendered and move it, however I cannot resize it. I can
    change the height and Width properties in the PropertyGrid and they
    change, but the control doesn't resize.

    When using the mouse to change the size, the control doesn't actually
    resize, but the Width and Height properties do change. I can save the
    changes, close the webform and open it again and it will display as I
    had resized it. Here's a summary of what happens when I use the size
    grips (the white boxes at each compass point that allow resizing with
    the mouse). None of the these will change the size, some move the
    control, some don't even affect the control - but all change the width
    and height properties.

    N: Moves the control up and down.
    NW: Move the control in all directions.
    W: Moves the control left and right
    SW: Moves the control left and right.
    S: No movement
    SE: No movement
    E: No movement
    NE: Move the control up and down.

    You can see for yourselves, below is the code for a simple control that
    does the same:

    Any ideas, it seems that the control is not resizing and re-rendering.
    In WindowsForms you would capture the OnResize event and call
    Me.Invalidate.

    Thanks

    Alex

    #######Code Start########
    Imports System.ComponentModel
    Imports System.Web.UI
    Imports System.Web.UI.WebControls

    <ToolboxData("<{0}:ctlTestGrid runat=server></{0}:TestGrid>")> _
    Public Class TestGrid

    Inherits System.Web.UI.WebControls.WebControl

    Protected Overrides Sub Render(ByVal output As
    System.Web.UI.HtmlTextWriter)
    EnsureChildControls()
    Me.RenderChildren(output)
    End Sub

    Protected Overrides Sub CreateChildControls()

    Dim objTable As New Web.UI.WebControls.Table
    For intRow As Int32 = 1 To 5
    objTable.Rows.Add(New TableRow)
    For intColumn As Int32 = 1 To 5
    objTable.Rows(intRow - 1).Cells.Add(New TableCell)
    objTable.Rows(intRow - 1).Cells(intColumn - 1).Text =
    "######"
    Next
    Next

    objTable.Width = MyBase.Width
    objTable.Height = MyBase.Height

    Me.Controls.Add(objTable)

    End Sub

    End Class
    #######Code End########
     
    Chubby Arse, Oct 6, 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. Replies:
    0
    Views:
    721
  2. Chubby Arse
    Replies:
    0
    Views:
    557
    Chubby Arse
    Oct 6, 2005
  3. Replies:
    0
    Views:
    601
  4. Replies:
    1
    Views:
    377
    Teemu Keiski
    Jul 2, 2003
  5. Zarko Gajic

    Child control renders at desing-time as if it is in run-time...

    Zarko Gajic, Mar 14, 2005, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    134
    Zarko Gajic
    Mar 16, 2005
Loading...

Share This Page