Brug af GUI
jeg har en form jeg vil instantiere som et objekt.Dvs VentDialog vent = new VentDialog("","");
Jeg ønsker ikke at bruge Application.Run()
Når jeg bruger Application.Run() Virker guiøen, men når jeg instantierer den på første måde kan jeg ikke se de to labels guiøen indeholder.
Hvad er der galt?
kode:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Threading;
namespace TidsurClient
{
public class VentDialog : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblMessage1;
private System.Windows.Forms.Label lblMessage2;
private System.ComponentModel.Container components = null;
private string message1="", message2="";
private System.Windows.Forms.GroupBox groupBox1;
public VentDialog(string message_1, string message_2)
{
message1 = message_1;
message2 = message_2;
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
public string Message1
{
set
{
this.message1 = value;
}
}
public string Message2
{
set
{
this.message2 = value;
}
}
#region Windows Form Designer generated code
public void InitializeComponent()
{
this.lblMessage1 = new System.Windows.Forms.Label();
this.lblMessage2 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// lblMessage1
//
this.lblMessage1.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.lblMessage1.Font = new System.Drawing.Font("Arial", 12.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblMessage1.Location = new System.Drawing.Point(16, 24);
this.lblMessage1.Name = "lblMessage1";
this.lblMessage1.Size = new System.Drawing.Size(208, 40);
this.lblMessage1.TabIndex = 0;
this.lblMessage1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.lblMessage1.Text = message1;
//
// lblMessage2
//
this.lblMessage2.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblMessage2.Location = new System.Drawing.Point(16, 75);
this.lblMessage2.Name = "lblMessage2";
this.lblMessage2.Size = new System.Drawing.Size(208, 40);
this.lblMessage2.TabIndex = 1;
this.lblMessage2.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.lblMessage2.Text = message2;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.lblMessage2);
this.groupBox1.Controls.Add(this.lblMessage1);
this.groupBox1.Location = new System.Drawing.Point(8, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(232, 136);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
//
// VentDialog
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(248, 157);
this.Controls.Add(this.groupBox1);
this.Name = "VentDialog";
this.Text = "VentDialog";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
}
}
