|
Reason for my vote of 1
Not a very clear example and responses to posts condescending.
|
|
|
|
|
- but I managed it... (this is not your fault, but my bad english..)
If the designer would let you set this property the user-control would be docked in the design view. I understand why this property was hidden (anyway why should a control be "docked" by design? - this should always be controlled by the container in my opinion.)
What I'm wondering is why you had difficulties to implement this feature (you are well known here on cp - and I think you are a real expert )
There is also another possibility (but it works only for containers that not contain any other controls)- use the Docking attribute for your UserControl:
[Docking(DockingBehavior.AutoDock)]
public partial class IWantToFillMyContainer_UserControl : UserControl
|
|
|
|
|
I'm a bit confused... the hierarchy is:
FORM contains PANEL (anchored) contains USER CONTROL contains FILLING CONTROL (dock Fill).
Of course the user control won't resize because even though the PANEL resizes due to its anchor settings, there has been nothing set to ask the UC to resize. Wouldn't you just want to set the UC to dock Fill too?
|
|
|
|
|
My point was that there is no way to do this *in the designer* and that you have to remember to go to the actual source code to establish the desired behavior..45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
You can set this in the designer. Let's see if I can post enough to show (I wish I could upload a ZIP with the solution...)
I have a UserControl (MyUserCtrl) with a FULL docked TextBox (multiline so it fills the control). The UserControl has a padding value so the TextBox doesn't go all the way to the edges, plus a blue background so you can see the UserControl when displayed on the main form. The main form (Form1) contains an anchored Panel control. The Panel control contains an instance of MyUserCtrl docked FULL. When you resize the form, the panel resizes due to the anchoring, the UserControl resizes due to it being docked, and the TextBox resizes due to it being docked too. I didn't have to do anything in the source -- everything is in the designer.
I think this is what you're trying to do. If I missed the boat, my apologies...
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.Panel1 = New System.Windows.Forms.Panel
Me.MyUserCtrl1 = New ResizeTest.MyUserCtrl
Me.Panel1.SuspendLayout()
Me.SuspendLayout()
'
'Panel1
'
Me.Panel1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Panel1.Controls.Add(Me.MyUserCtrl1)
Me.Panel1.Location = New System.Drawing.Point(24, 22)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(374, 259)
Me.Panel1.TabIndex = 0
'
'MyUserCtrl1
'
Me.MyUserCtrl1.Dock = System.Windows.Forms.DockStyle.Fill
Me.MyUserCtrl1.Location = New System.Drawing.Point(0, 0)
Me.MyUserCtrl1.Name = "MyUserCtrl1"
Me.MyUserCtrl1.Size = New System.Drawing.Size(372, 257)
Me.MyUserCtrl1.TabIndex = 0
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(430, 307)
Me.Controls.Add(Me.Panel1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.Panel1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents MyUserCtrl1 As ResizeTest.MyUserCtrl
End Class
Partial Class MyUserCtrl
Inherits System.Windows.Forms.UserControl
'UserControl overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Dock = System.Windows.Forms.DockStyle.Fill
Me.TextBox1.Location = New System.Drawing.Point(8, 8)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(468, 336)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "This textbox is docked FILL on the user control"
'
'MyUserCtrl
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.Color.Blue
Me.Controls.Add(Me.TextBox1)
Me.Name = "MyUserCtrl"
Me.Padding = New System.Windows.Forms.Padding(8)
Me.Size = New System.Drawing.Size(484, 352)
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
End Class
|
|
|
|
|
I try not to do *anything* in VB...
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|