2

私はWinFormsを初めて使用し、CSSでのスタイル設定に非常に慣れているため、WinFormのBottom Marginプロパティを正しく表示していない可能性がありますが、任意の大きな下マージン番号をどの要素に設定しても、まったく効果はありません。

私が欲しいのは、フォームのデザインを最初の表示可能なウィンドウの下に拡張し(垂直スクロールバーがうまく表示される)、要素の一番下が同じ高さにならないように、これらの要素に下マージンを設定することですウィンドウの一番下(少しスペースがあればいいのですが)。

問題を引き起こしているのが1つの要素(またはウィンドウの最初の表示部分から外れているという事実)だけであるかどうかを確認するために、いくつかの要素でこれを試しましたが、効果が得られないようですマージンプロパティからまったく外れています。

ここを見てください:http: //msdn.microsoft.com/en-us/library/ms229627.aspx これは確かに、marginプロパティが行うべきことのようです。また、どの要素のGUIコントロールにもパディングが見つかりません。

現状では、Visual Studioが2つの部分クラス(および他の.csファイル)内のどこにすべてを配置するかをよりよく理解するまで、ほとんどの場合、イベントハンドラーのC#のみをコーディングしています。

それが役立つ場合は、デザイナーファイルのコードを次に示します。

namespace WindowsFormsApplication1
{
    partial class IntroForm
    {
        /// <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 Windows Form 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.WelcomeHeader = new System.Windows.Forms.Label();
        this.ActionSelect = new System.Windows.Forms.ComboBox();
        this.ProceedBtn = new System.Windows.Forms.Button();
        this.label1 = new System.Windows.Forms.Label();
        this.richTextBox1 = new System.Windows.Forms.RichTextBox();
        this.SuspendLayout();
        // 
        // WelcomeHeader
        // 
        this.WelcomeHeader.AutoSize = true;
        this.WelcomeHeader.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.WelcomeHeader.Location = new System.Drawing.Point(84, 30);
        this.WelcomeHeader.Name = "WelcomeHeader";
        this.WelcomeHeader.Size = new System.Drawing.Size(367, 25);
        this.WelcomeHeader.TabIndex = 0;
        this.WelcomeHeader.Text = "Please Select Which Content You";
        // 
        // ActionSelect
        // 
        this.ActionSelect.ForeColor = System.Drawing.SystemColors.WindowFrame;
        this.ActionSelect.FormattingEnabled = true;
        this.ActionSelect.Items.AddRange(new object[] {
        "Events",
        "Headline News",
        "Images For Slideshow",
        "Agendas",
        "Job Opportunities",
        "Schedule Of Meetings",
        "Legal Notices",
        "Main Street (Main Link)",
        "Tourism (Main Link)",
        "Rental Properties",
        "Concert In The Park",
        "Main Street News Letters"});
        this.ActionSelect.Location = new System.Drawing.Point(126, 116);
        this.ActionSelect.Name = "ActionSelect";
        this.ActionSelect.Size = new System.Drawing.Size(283, 28);
        this.ActionSelect.TabIndex = 1;
        this.ActionSelect.Text = "Please Select";
        // 
        // ProceedBtn
        // 
        this.ProceedBtn.BackColor = System.Drawing.SystemColors.ButtonFace;
        this.ProceedBtn.Cursor = System.Windows.Forms.Cursors.Hand;
        this.ProceedBtn.ForeColor = System.Drawing.Color.DimGray;
        this.ProceedBtn.Location = new System.Drawing.Point(221, 192);
        this.ProceedBtn.Name = "ProceedBtn";
        this.ProceedBtn.Size = new System.Drawing.Size(93, 34);
        this.ProceedBtn.TabIndex = 2;
        this.ProceedBtn.Text = "Proceed";
        this.ProceedBtn.UseVisualStyleBackColor = false;
        this.ProceedBtn.Click += new System.EventHandler(this.ProceedBtn_Click);
        // 
        // label1
        // 
        this.label1.AutoSize = true;
        this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.label1.Location = new System.Drawing.Point(142, 55);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(251, 25);
        this.label1.TabIndex = 3;
        this.label1.Text = "Would Like To Change";
        // 
        // richTextBox1
        // 
        this.richTextBox1.Location = new System.Drawing.Point(147, 268);
        this.richTextBox1.Margin = new System.Windows.Forms.Padding(3, 3, 3, 30);
        this.richTextBox1.Name = "richTextBox1";
        this.richTextBox1.Size = new System.Drawing.Size(246, 269);
        this.richTextBox1.TabIndex = 4;
        this.richTextBox1.Text = "";
        // 
        // IntroForm
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.AutoScroll = true;
        this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(102)))), ((int)(((byte)(0)))));
        this.ClientSize = new System.Drawing.Size(535, 306);
        this.Controls.Add(this.richTextBox1);
        this.Controls.Add(this.label1);
        this.Controls.Add(this.ProceedBtn);
        this.Controls.Add(this.ActionSelect);
        this.Controls.Add(this.WelcomeHeader);
        this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(153)))), ((int)(((byte)(0)))));
        this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
        this.Name = "IntroForm";
        this.Text = "Okmulgee Online Web File Generator";
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    #endregion

    private System.Windows.Forms.Label WelcomeHeader;
    private System.Windows.Forms.ComboBox ActionSelect;
    private System.Windows.Forms.Button ProceedBtn;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.RichTextBox richTextBox1;
}
}

- - - - - - - - - - - - - - - - - - - - - アップデート - - - - ------------------------------------

上記のコード内で下マージンプロパティを設定した要素は、単純にrichTextBox1です。

また、メインフォーム要素へのパディング要素を見つけましたが、残念ながら、これは他の要素をそのエッジから押しのけることはありません:(

これらのプロパティは何をしますか(マージン、パディング)?

4

1 に答える 1

6

Marginプロパティは、Winformsに組み込まれている自動レイアウト機能によって使用されます。ただし、要求されたマージンを提供できるように、コンテナーを成長させる必要があります。したがって、フォームのAutoSizeプロパティをTrueに設定する必要があります。

AutoSizeとAutoScrollを組み合わせることが可能であり、MaximumSizeプロパティを設定して、大きくなりすぎないようにすることができます。レイアウト計算でMaximumSizeを超えるレイアウトが生成されると、スクロールバーが自動的に表示されます。デフォルトの最大サイズは、フォームが表示されるScreen.WorkingAreaで、通常は十分です。

于 2013-02-04T16:05:01.067 に答える