Click here to Skip to main content
15,905,967 members
Home / Discussions / C#
   

C#

 
GeneralRe: doubt Pin
V.19-Apr-16 3:33
professionalV.19-Apr-16 3:33 
QuestionRe: doubt Pin
Eddy Vluggen18-Apr-16 4:33
professionalEddy Vluggen18-Apr-16 4:33 
AnswerRe: doubt Pin
Patrice T18-Apr-16 5:38
mvePatrice T18-Apr-16 5:38 
QuestionRoslyn compiler Pin
V.18-Apr-16 2:27
professionalV.18-Apr-16 2:27 
AnswerRe: Roslyn compiler Pin
Richard Deeming18-Apr-16 2:42
mveRichard Deeming18-Apr-16 2:42 
QuestionInsert rows c# Pin
Bougarra17-Apr-16 23:11
Bougarra17-Apr-16 23:11 
AnswerRe: Insert rows c# Pin
Pete O'Hanlon17-Apr-16 23:55
mvePete O'Hanlon17-Apr-16 23:55 
QuestionForm disappearing Pin
Member 238990017-Apr-16 0:02
Member 238990017-Apr-16 0:02 
Hi All

Would appreciate some help on the following code which results in the form disappearing, rather than persisiting. Probably something really silly (code newbie, please be gentle).


using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Windows.Forms;

namespace TCPReader
{

public class frmConfiguration : System.Windows.Forms.Form
{
private void frmConfiguration_Load(object sender, System.EventArgs e)
{
}
private System.Windows.Forms.Button btnok;
private System.Windows.Forms.Button button2;
private System.ComponentModel.IContainer components;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
public USBReader.readerqueue m_queue;
public USBReader.Socketclient m_sclient;
public System.Threading.Thread thread1;
public System.Threading.Thread threadClient;
private System.Windows.Forms.TextBox txtipaddres;
private System.Windows.Forms.TextBox txtportno;

private void btnok_Click(object sender, System.EventArgs e)
{
try
{
bool flag = txtipaddres.Text != "" && txtportno.Text != "";
if (!flag)
{
System.Windows.Forms.MessageBox.Show("Enter IP Address and Port No to Connet\n to the Node", "Node Control", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk);
Show();
}
else
{
System.IO.TextWriter textWriter = System.IO.File.CreateText(System.Windows.Forms.Application.StartupPath + "\\IPAddress.txt");
textWriter.WriteLine(txtportno.Text + ";" + txtipaddres.Text);
textWriter.Close();
DialogResult = System.Windows.Forms.DialogResult.OK;
Close();
}
}
catch (System.Exception e1)
{
}
}

private void button2_Click(object sender, System.EventArgs e)
{
DialogResult = System.Windows.Forms.DialogResult.Cancel;
Close();
}

private void Configuration_Load(object sender, System.EventArgs e)
{
bool flag = !System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + "\\IPAddress.txt");
if (!flag)
{
System.IO.TextReader textReader = System.IO.File.OpenText(System.Windows.Forms.Application.StartupPath + "\\IPAddress.txt");
string s = textReader.ReadLine();
textReader.Close();
char[] chArr = new char[] { ';' };
string[] sArr = s.Split(chArr);
txtportno.Text = sArr[0];
txtipaddres.Text = sArr[1];
}
else
{
txtipaddres.Text = "";
txtportno.Text = "";
}

}

private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.btnok = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.txtipaddres = new System.Windows.Forms.TextBox();
this.txtportno = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Palatino Linotype", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.SystemColors.HotTrack;
this.label1.Location = new System.Drawing.Point(24, 36);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(73, 18);
this.label1.TabIndex = 2;
this.label1.Text = "IP Address";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Palatino Linotype", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.ForeColor = System.Drawing.SystemColors.HotTrack;
this.label2.Location = new System.Drawing.Point(42, 72);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(55, 18);
this.label2.TabIndex = 3;
this.label2.Text = "Port No";
//
// btnok
//
this.btnok.BackColor = System.Drawing.Color.AliceBlue;
this.btnok.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnok.Font = new System.Drawing.Font("Palatino Linotype", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnok.ForeColor = System.Drawing.SystemColors.HotTrack;
this.btnok.Location = new System.Drawing.Point(103, 114);
this.btnok.Name = "btnok";
this.btnok.Size = new System.Drawing.Size(69, 23);
this.btnok.TabIndex = 3;
this.btnok.Text = "O&k";
this.btnok.UseVisualStyleBackColor = false;
this.btnok.Click += new System.EventHandler(this.btnok_Click);
//
// button2
//
this.button2.BackColor = System.Drawing.Color.AliceBlue;
this.button2.Cursor = System.Windows.Forms.Cursors.Default;
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button2.Font = new System.Drawing.Font("Palatino Linotype", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button2.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button2.Location = new System.Drawing.Point(189, 114);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(69, 23);
this.button2.TabIndex = 4;
this.button2.Text = "&Cancel";
this.button2.UseVisualStyleBackColor = false;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.txtipaddres);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.txtportno);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.btnok);
this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Font = new System.Drawing.Font("Palatino Linotype", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.groupBox1.ForeColor = System.Drawing.SystemColors.HotTrack;
this.groupBox1.Location = new System.Drawing.Point(23, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(288, 158);
this.groupBox1.TabIndex = 8;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Configuration";
this.groupBox1.Enter += new System.EventHandler(this.groupBox1_Enter);
//
// txtipaddres
//
this.txtipaddres.BackColor = System.Drawing.SystemColors.Window;
this.txtipaddres.Location = new System.Drawing.Point(103, 36);
this.txtipaddres.Name = "txtipaddres";
this.txtipaddres.Size = new System.Drawing.Size(155, 25);
this.txtipaddres.TabIndex = 1;
this.txtipaddres.TextChanged += new System.EventHandler(this.txtipaddres_TextChanged);
//
// txtportno
//
this.txtportno.BackColor = System.Drawing.SystemColors.Window;
this.txtportno.Location = new System.Drawing.Point(103, 72);
this.txtportno.Name = "txtportno";
this.txtportno.Size = new System.Drawing.Size(155, 25);
this.txtportno.TabIndex = 2;
//
// frmConfiguration
//
this.AcceptButton = this.btnok;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Snow;
this.ClientSize = new System.Drawing.Size(335, 197);
this.ControlBox = false;
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "frmConfiguration";
this.Load += new System.EventHandler(this.Configuration_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);

}

protected override void Dispose(bool disposing)
{
bool flag = !disposing || (components == null);
if (!flag)
components.Dispose();
base.Dispose(disposing);
}

private void groupBox1_Enter(object sender, EventArgs e)
{

}

private void txtipaddres_TextChanged(object sender, EventArgs e)
{

}

} // class frmConfiguration

}</pre>



Regards
Active
AnswerRe: Form disappearing Pin
OriginalGriff17-Apr-16 0:36
mveOriginalGriff17-Apr-16 0:36 
GeneralRe: Form disappearing Pin
Member 238990017-Apr-16 0:46
Member 238990017-Apr-16 0:46 
GeneralRe: Form disappearing Pin
OriginalGriff17-Apr-16 0:50
mveOriginalGriff17-Apr-16 0:50 
GeneralRe: Form disappearing Pin
Member 238990017-Apr-16 0:55
Member 238990017-Apr-16 0:55 
GeneralRe: Form disappearing Pin
OriginalGriff17-Apr-16 1:06
mveOriginalGriff17-Apr-16 1:06 
GeneralRe: Form disappearing Pin
Member 238990017-Apr-16 1:16
Member 238990017-Apr-16 1:16 
GeneralRe: Form disappearing Pin
OriginalGriff17-Apr-16 1:30
mveOriginalGriff17-Apr-16 1:30 
GeneralRe: Form disappearing Pin
Member 238990017-Apr-16 1:42
Member 238990017-Apr-16 1:42 
GeneralRe: Form disappearing Pin
OriginalGriff17-Apr-16 1:44
mveOriginalGriff17-Apr-16 1:44 
GeneralRe: Form disappearing Pin
OriginalGriff17-Apr-16 1:40
mveOriginalGriff17-Apr-16 1:40 
GeneralRe: Form disappearing Pin
Philippe Mori18-Apr-16 12:34
Philippe Mori18-Apr-16 12:34 
AnswerRe: Form disappearing Pin
ChizI19-Apr-16 7:25
ChizI19-Apr-16 7:25 
Questionusing Enums as a design-strategy ? Pin
BillWoodruff16-Apr-16 21:59
professionalBillWoodruff16-Apr-16 21:59 
AnswerRe: using Enums as a design-strategy ? Pin
Garth J Lancaster16-Apr-16 23:01
professionalGarth J Lancaster16-Apr-16 23:01 
GeneralRe: using Enums as a design-strategy ? Pin
BillWoodruff16-Apr-16 23:29
professionalBillWoodruff16-Apr-16 23:29 
AnswerRe: using Enums as a design-strategy ? Pin
John Torjo18-Apr-16 1:37
professionalJohn Torjo18-Apr-16 1:37 
GeneralRe: using Enums as a design-strategy ? Pin
BillWoodruff18-Apr-16 4:45
professionalBillWoodruff18-Apr-16 4:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.