By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,417 Members | 1,845 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,417 IT Pros & Developers. It's quick & easy.

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

P: n/a
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########

Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.