Note that there are some explanatory texts on larger screens.

plurals
  1. POHiding DateTimePicker's text and Usercontrol resize
    primarykey
    data
    text
    <p>I have a user control which has a DateTimePicker overlaid with the single line text box(Tb)<br> covering the text part of DateTimePicker. The textbox Tb (<strong>green</strong>) is anchored (L T R B). </p> <p><img src="https://i.stack.imgur.com/BcN1h.png" alt="Datepicker overlaid with textbox"></p> <p>The problem comes when the usercontrol is resized.<br> The overlaid datetimepicker shows up behind the text Tb.</p> <p><img src="https://i.stack.imgur.com/pKtxB.png" alt="The overlaid datetimepicker shows up behind the green textbox Tb."></p> <p>Currently the user control is 242(W) x 20(H) . Problems shows up when control is resized below 100 (Width) .</p> <p>I tried the blank the text with CustomFormat set to " " but the user control supports many of the datetimepicker functionalities so that was not an option.</p> <p>I tried to set the minimum size on the user control but that doesn't work too.</p> <p><strong>Edit:</strong><br> The control is already in use in few applications.In those applications the minimum size of the control is 90X20 whereas the minimum size which we set now is 97x20.<br> Will VS designer size the existing controls to 97x20 after making the change?<br> How to achieve this effect(re-size to 97x20)? </p> <p><strong>Edit</strong> ****code after adding minimum size****</p> <pre><code>namespace WindowsFormsApplication1 { partial class CDatePicker { private System.ComponentModel.IContainer components = null; protected override void Dispose(bool disposing) { if (disposing &amp;&amp; (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Component Designer generated code private void InitializeComponent() { this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.datepanel = new System.Windows.Forms.Panel(); this.datetxt = new System.Windows.Forms.TextBox(); this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker(); this.timepanel = new System.Windows.Forms.Panel(); this.timetxt = new System.Windows.Forms.TextBox(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); this.datepanel.SuspendLayout(); this.timepanel.SuspendLayout(); this.SuspendLayout(); // // splitContainer1 // this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer1.Location = new System.Drawing.Point(0, 0); this.splitContainer1.Name = "splitContainer1"; // // splitContainer1.Panel1 // this.splitContainer1.Panel1.Controls.Add(this.datepanel); this.splitContainer1.Panel1MinSize = 105; // // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.timepanel); this.splitContainer1.Size = new System.Drawing.Size(236, 20); this.splitContainer1.SplitterDistance = 178; this.splitContainer1.SplitterWidth = 1; this.splitContainer1.TabIndex = 0; // // datepanel // this.datepanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.datepanel.Controls.Add(this.datetxt); this.datepanel.Controls.Add(this.dateTimePicker1); this.datepanel.Location = new System.Drawing.Point(0, 0); this.datepanel.Margin = new System.Windows.Forms.Padding(0); this.datepanel.Name = "datepanel"; this.datepanel.Size = new System.Drawing.Size(175, 20); this.datepanel.TabIndex = 0; // // datetxt // this.datetxt.BackColor = System.Drawing.Color.Gainsboro; this.datetxt.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.datetxt.Location = new System.Drawing.Point(0, 0); this.datetxt.MinimumSize = new System.Drawing.Size(60, 20); this.datetxt.Name = "datetxt"; this.datetxt.Size = new System.Drawing.Size(71, 20); this.datetxt.TabIndex = 3; this.datetxt.Text = "date"; // // dateTimePicker1 // this.dateTimePicker1.Dock = System.Windows.Forms.DockStyle.Fill; this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Short; this.dateTimePicker1.Location = new System.Drawing.Point(0, 0); this.dateTimePicker1.Margin = new System.Windows.Forms.Padding(0); this.dateTimePicker1.MinimumSize = new System.Drawing.Size(65, 20); this.dateTimePicker1.Name = "dateTimePicker1"; this.dateTimePicker1.Size = new System.Drawing.Size(175, 20); this.dateTimePicker1.TabIndex = 2; this.dateTimePicker1.Value = new System.DateTime(2012, 11, 15, 0, 0, 0, 0); // // timepanel // this.timepanel.Controls.Add(this.timetxt); this.timepanel.Dock = System.Windows.Forms.DockStyle.Fill; this.timepanel.Location = new System.Drawing.Point(0, 0); this.timepanel.Margin = new System.Windows.Forms.Padding(0); this.timepanel.Name = "timepanel"; this.timepanel.Size = new System.Drawing.Size(57, 20); this.timepanel.TabIndex = 0; // // timetxt // this.timetxt.Dock = System.Windows.Forms.DockStyle.Fill; this.timetxt.Location = new System.Drawing.Point(0, 0); this.timetxt.Name = "timetxt"; this.timetxt.Size = new System.Drawing.Size(57, 20); this.timetxt.TabIndex = 1; this.timetxt.Text = "time"; this.timetxt.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // CDatePicker // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; this.Controls.Add(this.splitContainer1); this.MaximumSize = new System.Drawing.Size(236, 20); this.MinimumSize = new System.Drawing.Size(100, 20); this.Name = "CDatePicker"; this.Size = new System.Drawing.Size(236, 20); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); this.splitContainer1.ResumeLayout(false); this.datepanel.ResumeLayout(false); this.datepanel.PerformLayout(); this.timepanel.ResumeLayout(false); this.timepanel.PerformLayout(); this.ResumeLayout(false); } #endregion private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.Panel datepanel; private System.Windows.Forms.TextBox datetxt; private System.Windows.Forms.DateTimePicker dateTimePicker1; private System.Windows.Forms.Panel timepanel; private System.Windows.Forms.TextBox timetxt; } } </code></pre> <p>Edit : After adding min sizes, it looks better but the calender drop down disappears<br> when the control is resized to min and the project is rebuilt..<br> Also the text box doesn't remain anchored near the calender button.. </p> <p>edit: pic added for above..calender disappears.</p> <p><img src="https://i.stack.imgur.com/Ukxn4.png" alt="date calender disappears"></p> <p><strong>Edit</strong> : Oh i missed one more thing both the date field and time field are collapsible.thats why the split container is there. Minimum size calculations must also be aware of this.(i guess 2 different min. sizes depending on visibility of time field.)</p> <p><strong>Questions:</strong> </p> <p>a) How can i prevent the usercontrol from resizing beyond certain min limit to avoid above problem? (pic1 seems to be idea size)</p> <p>b) Can i draw the datetimepicker such that the text is blanked out and we only see the<br> calender dropdown button? If so will i still need to handle resize events?</p> <p>c) How can i keep resizing the textbox so that it always covers the date text part of DTP. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload