いつもおせわになります。
Windows7, Visual Studio 2013, .NET4.5, WindowsFormの組み合わせで開発しています。
TableLayoutPanelにPanelをコードで追加したいです。
図1がデザイン。
図2が実行した状態です。
実行すると、元のlabel0(Panel0)のすぐ下でなく、なぞの空間の下にPanelを追加します。
図2の希望の位置にPalelをコードで追加するには、どうすればよいでしょう。
お知恵をお貸しください。
Form1.cs
using System.Windows.Forms;
namespace tabletest {
public partial class Form1 : Form {
int counter = 0;
int lineheight = 100;
public Form1() {
InitializeComponent();
Panel panel = new Panel(); panel.Width = 598; panel.BackColor = System.Drawing.SystemColors.ButtonShadow; Label label = new Label(); label.Text = "label"; label.Location = new System.Drawing.Point(0, 0); label.Width = 500; panel.Controls.Add(label); table.Controls.Add(panel, 0, counter); table.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, lineheight)); } }
}
Form1.Designer.cs
namespace tabletest {
partial class Form1 {
/// <summary>
/// 必要なデザイナー変数です。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary> /// 使用中のリソースをすべてクリーンアップします。 /// </summary> /// <param name="disposing">マネージ リソースが破棄される場合 true、破棄されない場合は false です。</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows フォーム デザイナーで生成されたコード /// <summary> /// デザイナー サポートに必要なメソッドです。このメソッドの内容を /// コード エディターで変更しないでください。 /// </summary> private void InitializeComponent() { this.table = new System.Windows.Forms.TableLayoutPanel(); this.panel0 = new System.Windows.Forms.Panel(); this.label0 = new System.Windows.Forms.Label(); this.table.SuspendLayout(); this.panel0.SuspendLayout(); this.SuspendLayout(); // // table // this.table.AutoScroll = true; this.table.BackColor = System.Drawing.SystemColors.ActiveCaption; this.table.ColumnCount = 1; this.table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.table.Controls.Add(this.panel0, 0, 0); this.table.Location = new System.Drawing.Point(93, 12); this.table.Name = "table"; this.table.RowCount = 1; this.table.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 435F)); this.table.Size = new System.Drawing.Size(596, 612); this.table.TabIndex = 0; // // panel0 // this.panel0.BackColor = System.Drawing.SystemColors.ButtonShadow; this.panel0.Controls.Add(this.label0); this.panel0.Location = new System.Drawing.Point(3, 3); this.panel0.Name = "panel0"; this.panel0.Size = new System.Drawing.Size(383, 103); this.panel0.TabIndex = 0; // // label0 // this.label0.AutoSize = true; this.label0.Location = new System.Drawing.Point(32, 18); this.label0.Name = "label0"; this.label0.Size = new System.Drawing.Size(35, 12); this.label0.TabIndex = 0; this.label0.Text = "label0"; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(813, 636); this.Controls.Add(this.table); this.Name = "Form1"; this.Text = "Form1"; this.table.ResumeLayout(false); this.panel0.ResumeLayout(false); this.panel0.PerformLayout(); this.ResumeLayout(false); } #endregion private System.Windows.Forms.TableLayoutPanel table; private System.Windows.Forms.Panel panel0; private System.Windows.Forms.Label label0; }
}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2016/01/22 02:23