Results 1 to 8 of 8

Thread: User Control being "truncated"

  1. #1

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,612

    User Control being "truncated"

    I have a user control on a form and the bottom of it is getting lopped off for some reason.

    Here's the user control in the designer:-
    Name:  UserControl.jpg
Views: 274
Size:  13.0 KB

    And here's how it appears when added to a form. Note the bottom's been lopped off.
    Name:  ControlOnForm.PNG
Views: 246
Size:  20.2 KB

    I can delete and add the control back in. It looks correct.
    Name:  DeleteAndAddBack.PNG
Views: 232
Size:  20.7 KB

    But as soon as I rebuild it goes screwy again.
    Name:  Rebuild.PNG
Views: 230
Size:  18.1 KB

    The Test Connection Button and property grid are anchored to the bottom of the user control so any resizing of the control on the form should reposition the button apropriately rather than just lopping it off. At the moment I've ammended the user control to have a "dead" area at the bottom which I don't mind being lopped off but that feels a bit shoddy and I'd rather get to the bottom of the porblem if I can.

    Any idea what's going on here?
    You can depend upon the Americans to do the right thing. But only after they have exhausted every other possibility - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  2. #2
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: User Control being "truncated"

    Could you post the UC's designer code file and any UI customizations in the main code file?

  3. #3

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,612

    Re: User Control being "truncated"

    There are no UI Customizations in the man file.

    Here's the designer code:-
    Code:
     partial class ConnectionStringBuilder
        {
            /// <summary> 
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
    
            /// <summary> 
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
    
            #region Component Designer generated code
    
            /// <summary> 
            /// Required method for Designer support - do not modify 
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.toolStrip1 = new System.Windows.Forms.ToolStrip();
                this.toolStripDropDownButtonProvider = new System.Windows.Forms.ToolStripDropDownButton();
                this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
                this.buttonTestConnection = new System.Windows.Forms.Button();
                this.toolStrip1.SuspendLayout();
                this.SuspendLayout();
                // 
                // toolStrip1
                // 
                this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.toolStripDropDownButtonProvider});
                this.toolStrip1.Location = new System.Drawing.Point(0, 0);
                this.toolStrip1.Name = "toolStrip1";
                this.toolStrip1.Size = new System.Drawing.Size(629, 27);
                this.toolStrip1.TabIndex = 0;
                this.toolStrip1.Text = "toolStrip1";
                // 
                // toolStripDropDownButtonProvider
                // 
                this.toolStripDropDownButtonProvider.Image = global::ProdapsClusterViewer.Properties.Resources.DataSources;
                this.toolStripDropDownButtonProvider.ImageTransparentColor = System.Drawing.Color.Magenta;
                this.toolStripDropDownButtonProvider.Name = "toolStripDropDownButtonProvider";
                this.toolStripDropDownButtonProvider.Size = new System.Drawing.Size(164, 24);
                this.toolStripDropDownButtonProvider.Text = "Choose Sql Flavour";
                this.toolStripDropDownButtonProvider.ToolTipText = "Choose SQL Flavour";
                // 
                // propertyGrid1
                // 
                this.propertyGrid1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
                | System.Windows.Forms.AnchorStyles.Right)));
                this.propertyGrid1.Location = new System.Drawing.Point(4, 34);
                this.propertyGrid1.Margin = new System.Windows.Forms.Padding(4);
                this.propertyGrid1.Name = "propertyGrid1";
                this.propertyGrid1.Size = new System.Drawing.Size(621, 370);
                this.propertyGrid1.TabIndex = 1;
                // 
                // buttonTestConnection
                // 
                this.buttonTestConnection.Anchor = System.Windows.Forms.AnchorStyles.Left;
                this.buttonTestConnection.Location = new System.Drawing.Point(4, 412);
                this.buttonTestConnection.Margin = new System.Windows.Forms.Padding(4);
                this.buttonTestConnection.Name = "buttonTestConnection";
                this.buttonTestConnection.Size = new System.Drawing.Size(160, 28);
                this.buttonTestConnection.TabIndex = 2;
                this.buttonTestConnection.Text = "&Test Connection";
                this.buttonTestConnection.UseVisualStyleBackColor = true;
                this.buttonTestConnection.Click += new System.EventHandler(this.buttonTestConnection_Click);
                // 
                // ConnectionStringBuilder
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.Controls.Add(this.buttonTestConnection);
                this.Controls.Add(this.propertyGrid1);
                this.Controls.Add(this.toolStrip1);
                this.Margin = new System.Windows.Forms.Padding(4);
                this.Name = "ConnectionStringBuilder";
                this.Size = new System.Drawing.Size(629, 486);
                this.Load += new System.EventHandler(this.ConnectionStringBuilder_Load);
                this.toolStrip1.ResumeLayout(false);
                this.toolStrip1.PerformLayout();
                this.ResumeLayout(false);
                this.PerformLayout();
    
            }
    
            #endregion
    
            private System.Windows.Forms.ToolStrip toolStrip1;
            private System.Windows.Forms.ToolStripDropDownButton toolStripDropDownButtonProvider;
            private System.Windows.Forms.PropertyGrid propertyGrid1;
            private System.Windows.Forms.Button buttonTestConnection;
        }
    You can depend upon the Americans to do the right thing. But only after they have exhausted every other possibility - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    35,239

    Re: User Control being "truncated"

    What's your platform? I've started seeing something like this on a Win8.1 Surface, though I have yet to track down a cause (or even look, for that matter).
    My usual boring signature: Nothing

  5. #5
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: User Control being "truncated"

    I can not reproduce your problem. The only thing that I can think of is that you been building up this control bit by bit with intermediate builds and the designer has cached instances that are causing problems. This seems unlikely though considering how simple this control is, but try exiting VS and do a Clean/Build cycle after you restart.

    Edit: Make sure the Form designer is closed or delete the control from the Form first.
    Last edited by TnTinMN; Dec 15th, 2014 at 10:16 AM.

  6. #6

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,612

    Re: User Control being "truncated"

    What's your platform?
    Win 7.

    Clean/Build cycle after you restart
    Already tried that. Turning VS off and on again fixes an uncomfortable number of mysterious behaviours

    I've got a vague memory of something like this no a project I worked on years ago. I think the problem was something to do with the access level on the control. I'm damned if I can remember what the solution was, though, or even if the problem was exactly the same as this so it could be a red herring.
    You can depend upon the Americans to do the right thing. But only after they have exhausted every other possibility - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  7. #7
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: User Control being "truncated"

    To be honest, I rarely use the UserControl template as I ran into issues with it when I first started with .Net and I moved to just writing my own inherited controls. It was probably my lack of knowledge at the time, but it worked for me.

    That said and using a little C&P, give this a try and see what happens:
    Code:
        public class CSB : System.Windows.Forms.ContainerControl
        {
            private System.Windows.Forms.ToolStrip toolStrip1;
            private System.Windows.Forms.ToolStripDropDownButton toolStripDropDownButtonProvider;
            private System.Windows.Forms.PropertyGrid propertyGrid1;
            private System.Windows.Forms.Button buttonTestConnection;
    
            public CSB()
            {
                this.toolStrip1 = new System.Windows.Forms.ToolStrip();
                this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
                this.buttonTestConnection = new System.Windows.Forms.Button();
                this.toolStripDropDownButtonProvider = new System.Windows.Forms.ToolStripDropDownButton();
                this.toolStrip1.SuspendLayout();
                this.SuspendLayout();
                // 
                // toolStrip1
                // 
                this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.toolStripDropDownButtonProvider});
                this.toolStrip1.Location = new System.Drawing.Point(0, 0);
                this.toolStrip1.Name = "toolStrip1";
                this.toolStrip1.Size = new System.Drawing.Size(472, 25);
                this.toolStrip1.TabIndex = 0;
                this.toolStrip1.Text = "toolStrip1";
                // 
                // propertyGrid1
                // 
                this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Top;
                this.propertyGrid1.Location = new System.Drawing.Point(0, 25);
                this.propertyGrid1.Name = "propertyGrid1";
                this.propertyGrid1.Size = new System.Drawing.Size(472, 301);
                this.propertyGrid1.TabIndex = 1;
                // 
                // buttonTestConnection
                // 
                this.buttonTestConnection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
                this.buttonTestConnection.Location = new System.Drawing.Point(0, 336);
                this.buttonTestConnection.Name = "buttonTestConnection";
                this.buttonTestConnection.Size = new System.Drawing.Size(120, 23);
                this.buttonTestConnection.TabIndex = 2;
                this.buttonTestConnection.Text = "&Test Connection";
                this.buttonTestConnection.UseVisualStyleBackColor = true;
                // 
                // toolStripDropDownButtonProvider
                // 
                //  ****************************** Set your Image
                this.toolStripDropDownButtonProvider.Image = global::WindowsFormsApplication1.Properties.Resources.m1;
                //  ******************************
                this.toolStripDropDownButtonProvider.ImageTransparentColor = System.Drawing.Color.Magenta;
                this.toolStripDropDownButtonProvider.Name = "toolStripDropDownButtonProvider";
                this.toolStripDropDownButtonProvider.Size = new System.Drawing.Size(137, 22);
                this.toolStripDropDownButtonProvider.Text = "Choose Sql Flavour";
                this.toolStripDropDownButtonProvider.ToolTipText = "Choose SQL Flavour";
                // 
                // ConnectionStringBuilder
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.Controls.Add(this.buttonTestConnection);
                this.Controls.Add(this.propertyGrid1);
                this.Controls.Add(this.toolStrip1);
                this.Name = "ConnectionStringBuilder";
                this.Size = new System.Drawing.Size(472, 364);
                this.toolStrip1.ResumeLayout(false);
                this.toolStrip1.PerformLayout();
                this.ResumeLayout(false);
                this.PerformLayout();
            }
    
        }
    You know, I would have thought that a good Moderator would have moved this thread to the appropriate (Language) Forum!

  8. #8

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,612

    Re: User Control being "truncated"

    the appropriate (Language) Forum
    It's fair cop, guv. I wasn't expecting to have to post code when I started the thread so I went with the busier VB forum.
    You can depend upon the Americans to do the right thing. But only after they have exhausted every other possibility - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

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