I have the following code attached to SelectedIndexChange event of comoBox5:
private void comboBox5_SelectedIndexChanged(object sender, EventArgs e)
{
_selectedValue = (int) comboBox5.SelectedValue;
textBox1.Text = _selectedValue.ToString();
}
which works fine, except that it has a non desire side effect. When ever such code is active you will need to click twice the close button of the form (X) in order to close it. Any ideas on how to avoid this side effect??

VulpesRank #55 · 29.2K reputationPosted Aug 8, 2014, 1:20 PM EDT
Guest UserRank #259 · 9.8K reputationPosted Jul 26, 2014, 9:16 PM EDT
Mario Cuervo26 reputationPosted Jul 28, 2014, 9:45 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jul 28, 2014, 2:35 PM EDT
Are you handling the FormClosing event as well?
If so, can you post the code.
Guest UserRank #259 · 9.8K reputationPosted Jul 29, 2014, 2:45 AM EDT
Mario Cuervo26 reputationPosted Jul 31, 2014, 9:50 AM EDT
Guest UserRank #259 · 9.8K reputationPosted Aug 1, 2014, 1:01 AM EDT
VulpesRank #55 · 29.2K reputationPosted Aug 1, 2014, 3:48 AM EDT
Are you accessing this field anywhere else within the form and, if so, could what you're doing conceivably affect the closure of the form?
Mario Cuervo26 reputationPosted Aug 1, 2014, 9:19 AM EDT
With no effect in the need for double clicking to close the form
Sumit, I could not open your sln because it was created with a different version of VS, I am using VS 10.
VulpesRank #55 · 29.2K reputationPosted Aug 1, 2014, 10:59 AM EDT
As we seem to have exhausted all the possibilities as regards code you've written yourself, that just leaves code generated by the VS designer.
This can sometimes indicate problems such as event-handlers being wired up to the wrong events.
So can you post the code for the Form's InitializeComponent() method and we'll see if we can spot anything that might account for the behavior you're seeing.
Mario Cuervo26 reputationPosted Aug 4, 2014, 8:30 AM EDT
Mario Cuervo26 reputationPosted Aug 5, 2014, 7:34 AM EDT
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.Label companyIDLabel;
System.Windows.Forms.Label nameLabel;
System.Windows.Forms.Label countryIDLabel;
System.Windows.Forms.Label creditRateLabel;
System.Windows.Forms.Label indIDLabel;
System.Windows.Forms.Label fISShrtNameLabel;
System.Windows.Forms.Label commentsLabel;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Company1));
this.panel1 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.companyBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.rEATCompanyDataSet = new REAT.REATCompanyDataSet();
this.label1 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.bindingNavigator1 = new System.Windows.Forms.BindingNavigator(this.components);
this.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton();
this.bindingNavigatorCountItem = new System.Windows.Forms.ToolStripLabel();
this.bindingNavigatorDeleteItem = new System.Windows.Forms.ToolStripButton();
this.bindingNavigatorMoveFirstItem = new System.Windows.Forms.ToolStripButton();
this.bindingNavigatorMovePreviousItem = new System.Windows.Forms.ToolStripButton();
this.bindingNavigatorSeparator = new System.Windows.Forms.ToolStripSeparator();
this.bindingNavigatorPositionItem = new System.Windows.Forms.ToolStripTextBox();
this.bindingNavigatorSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.bindingNavigatorMoveNextItem = new System.Windows.Forms.ToolStripButton();
this.bindingNavigatorMoveLastItem = new System.Windows.Forms.ToolStripButton();
this.bindingNavigatorSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripLabel1 = new System.Windows.Forms.ToolStripButton();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label3 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.commentsTextBox = new System.Windows.Forms.TextBox();
this.comboBox5 = new System.Windows.Forms.ComboBox();
this.CreditRatingbindingSource = new System.Windows.Forms.BindingSource(this.components);
this.companyCreditRatingDataSet = new REAT.CompanyCreditRatingDataSet();
this.fISShrtNameTextBox = new System.Windows.Forms.TextBox();
this.comboBox4 = new System.Windows.Forms.ComboBox();
this.rEATIndustryDataSet = new REAT.REATIndustryDataSet();
this.comboBox3 = new System.Windows.Forms.ComboBox();
this.rEATCountryDataSet = new REAT.REATCountryDataSet();
this.companyIDTextBox = new System.Windows.Forms.TextBox();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.companyTableAdapter = new REAT.REATCompanyDataSetTableAdapters.CompanyTableAdapter();
this.tableAdapterManager = new REAT.REATCompanyDataSetTableAdapters.TableAdapterManager();
this.CountrybindingSource = new System.Windows.Forms.BindingSource(this.components);
this.countryTableAdapter = new REAT.REATCountryDataSetTableAdapters.CountryTableAdapter();
this.IndustrybindingSource = new System.Windows.Forms.BindingSource(this.components);
this.industryTableAdapter = new REAT.REATIndustryDataSetTableAdapters.IndustryTableAdapter();
this.panel2 = new System.Windows.Forms.Panel();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.companyIDDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.fISShrtNameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.countryIDDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.indIDDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.creditRateDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Comments = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.companyCreditRatingsTableAdapter = new REAT.CompanyCreditRatingDataSetTableAdapters.CompanyCreditRatingsTableAdapter();
companyIDLabel = new System.Windows.Forms.Label();
nameLabel = new System.Windows.Forms.Label();
countryIDLabel = new System.Windows.Forms.Label();
creditRateLabel = new System.Windows.Forms.Label();
indIDLabel = new System.Windows.Forms.Label();
fISShrtNameLabel = new System.Windows.Forms.Label();
commentsLabel = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.companyBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.rEATCompanyDataSet)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingNavigator1)).BeginInit();
this.bindingNavigator1.SuspendLayout();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.CreditRatingbindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.companyCreditRatingDataSet)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.rEATIndustryDataSet)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.rEATCountryDataSet)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.CountrybindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.IndustrybindingSource)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// companyIDLabel
//
companyIDLabel.AutoSize = true;
companyIDLabel.Location = new System.Drawing.Point(6, 33);
companyIDLabel.Name = "companyIDLabel";
companyIDLabel.Size = new System.Drawing.Size(68, 13);
companyIDLabel.TabIndex = 0;
companyIDLabel.Text = "Company ID:";
//
// nameLabel
//
nameLabel.AutoSize = true;
nameLabel.Location = new System.Drawing.Point(6, 56);
nameLabel.Name = "nameLabel";
nameLabel.Size = new System.Drawing.Size(38, 13);
nameLabel.TabIndex = 2;
nameLabel.Text = "Name:";
//
// countryIDLabel
//
countryIDLabel.AutoSize = true;
countryIDLabel.Location = new System.Drawing.Point(6, 124);
countryIDLabel.Name = "countryIDLabel";
countryIDLabel.Size = new System.Drawing.Size(46, 13);
countryIDLabel.TabIndex = 4;
countryIDLabel.Text = "Country:";
//
// creditRateLabel
//
creditRateLabel.AutoSize = true;
creditRateLabel.Location = new System.Drawing.Point(6, 175);
creditRateLabel.Name = "creditRateLabel";
creditRateLabel.Size = new System.Drawing.Size(71, 13);
creditRateLabel.TabIndex = 6;
creditRateLabel.Text = "Credit Rating:";
//
// indIDLabel
//
indIDLabel.AutoSize = true;
indIDLabel.Location = new System.Drawing.Point(6, 147);
indIDLabel.Name = "indIDLabel";
indIDLabel.Size = new System.Drawing.Size(47, 13);
indIDLabel.TabIndex = 8;
indIDLabel.Text = "Industry:";
//
// fISShrtNameLabel
//
fISShrtNameLabel.AutoSize = true;
fISShrtNameLabel.Location = new System.Drawing.Point(6, 91);
fISShrtNameLabel.Name = "fISShrtNameLabel";
fISShrtNameLabel.Size = new System.Drawing.Size(76, 13);
fISShrtNameLabel.TabIndex = 11;
fISShrtNameLabel.Text = "FISShrt Name:";
//
// commentsLabel
//
commentsLabel.AutoSize = true;
commentsLabel.Location = new System.Drawing.Point(6, 202);
commentsLabel.Name = "commentsLabel";
commentsLabel.Size = new System.Drawing.Size(59, 13);
commentsLabel.TabIndex = 25;
commentsLabel.Text = "Comments:";
//
// panel1
//
this.panel1.Controls.Add(this.button1);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.comboBox2);
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.comboBox1);
this.panel1.Controls.Add(this.bindingNavigator1);
this.panel1.Location = new System.Drawing.Point(12, 12);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1190, 62);
this.panel1.TabIndex = 1;
//
// button1
//
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
this.button1.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.button1.Location = new System.Drawing.Point(967, 8);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(211, 37);
this.button1.TabIndex = 9;
this.button1.Text = "Export data to a CSV";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(580, 8);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(79, 13);
this.label2.TabIndex = 8;
this.label2.Text = "Search by Text";
//
// comboBox2
//
this.comboBox2.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Append;
this.comboBox2.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
this.comboBox2.DataSource = this.companyBindingSource;
this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox2.FormattingEnabled = true;
this.comboBox2.Location = new System.Drawing.Point(583, 24);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(349, 21);
this.comboBox2.TabIndex = 7;
//
// companyBindingSource
//
this.companyBindingSource.DataMember = "Company";
this.companyBindingSource.DataSource = this.rEATCompanyDataSet;
//
// rEATCompanyDataSet
//
this.rEATCompanyDataSet.DataSetName = "REATCompanyDataSet";
this.rEATCompanyDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(443, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(81, 13);
this.label1.TabIndex = 6;
this.label1.Text = "Search By Field";
//
// comboBox1
//
this.comboBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Append;
this.comboBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Items.AddRange(new object[] {
"Name"});
this.comboBox1.Location = new System.Drawing.Point(446, 24);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 21);
this.comboBox1.TabIndex = 5;
//
// bindingNavigator1
//
this.bindingNavigator1.AddNewItem = this.bindingNavigatorAddNewItem;
this.bindingNavigator1.AutoSize = false;
this.bindingNavigator1.BindingSource = this.companyBindingSource;
this.bindingNavigator1.CountItem = this.bindingNavigatorCountItem;
this.bindingNavigator1.DeleteItem = this.bindingNavigatorDeleteItem;
this.bindingNavigator1.Dock = System.Windows.Forms.DockStyle.None;
this.bindingNavigator1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.bindingNavigatorMoveFirstItem,
this.bindingNavigatorMovePreviousItem,
this.bindingNavigatorSeparator,
this.bindingNavigatorPositionItem,
this.bindingNavigatorCountItem,
this.bindingNavigatorSeparator1,
this.bindingNavigatorMoveNextItem,
this.bindingNavigatorMoveLastItem,
this.bindingNavigatorSeparator2,
this.bindingNavigatorAddNewItem,
this.toolStripSeparator2,
this.bindingNavigatorDeleteItem,
this.toolStripSeparator1,
this.toolStripLabel1});
this.bindingNavigator1.Location = new System.Drawing.Point(10, 20);
this.bindingNavigator1.MoveFirstItem = this.bindingNavigatorMoveFirstItem;
this.bindingNavigator1.MoveLastItem = this.bindingNavigatorMoveLastItem;
this.bindingNavigator1.MoveNextItem = this.bindingNavigatorMoveNextItem;
this.bindingNavigator1.MovePreviousItem = this.bindingNavigatorMovePreviousItem;
this.bindingNavigator1.Name = "bindingNavigator1";
this.bindingNavigator1.PositionItem = this.bindingNavigatorPositionItem;
this.bindingNavigator1.Size = new System.Drawing.Size(433, 25);
this.bindingNavigator1.TabIndex = 0;
this.bindingNavigator1.Text = "bindingNavigator1";
//
// bindingNavigatorAddNewItem
//
this.bindingNavigatorAddNewItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorAddNewItem.Image")));
this.bindingNavigatorAddNewItem.Name = "bindingNavigatorAddNewItem";
this.bindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorAddNewItem.Size = new System.Drawing.Size(74, 22);
this.bindingNavigatorAddNewItem.Text = "Add new";
this.bindingNavigatorAddNewItem.Click += new System.EventHandler(this.bindingNavigatorAddNewItem_Click);
//
// bindingNavigatorCountItem
//
this.bindingNavigatorCountItem.Name = "bindingNavigatorCountItem";
this.bindingNavigatorCountItem.Size = new System.Drawing.Size(35, 22);
this.bindingNavigatorCountItem.Text = "of {0}";
this.bindingNavigatorCountItem.ToolTipText = "Total number of items";
//
// bindingNavigatorDeleteItem
//
this.bindingNavigatorDeleteItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorDeleteItem.Image")));
this.bindingNavigatorDeleteItem.Name = "bindingNavigatorDeleteItem";
this.bindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorDeleteItem.Size = new System.Drawing.Size(60, 22);
this.bindingNavigatorDeleteItem.Text = "Delete";
//
// bindingNavigatorMoveFirstItem
//
this.bindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorMoveFirstItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveFirstItem.Image")));
this.bindingNavigatorMoveFirstItem.Name = "bindingNavigatorMoveFirstItem";
this.bindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMoveFirstItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorMoveFirstItem.Text = "Move first";
//
// bindingNavigatorMovePreviousItem
//
this.bindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorMovePreviousItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMovePreviousItem.Image")));
this.bindingNavigatorMovePreviousItem.Name = "bindingNavigatorMovePreviousItem";
this.bindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMovePreviousItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorMovePreviousItem.Text = "Move previous";
//
// bindingNavigatorSeparator
//
this.bindingNavigatorSeparator.Name = "bindingNavigatorSeparator";
this.bindingNavigatorSeparator.Size = new System.Drawing.Size(6, 25);
//
// bindingNavigatorPositionItem
//
this.bindingNavigatorPositionItem.AccessibleName = "Position";
this.bindingNavigatorPositionItem.AutoSize = false;
this.bindingNavigatorPositionItem.Name = "bindingNavigatorPositionItem";
this.bindingNavigatorPositionItem.Size = new System.Drawing.Size(50, 23);
this.bindingNavigatorPositionItem.Text = "0";
this.bindingNavigatorPositionItem.ToolTipText = "Current position";
//
// bindingNavigatorSeparator1
//
this.bindingNavigatorSeparator1.Name = "bindingNavigatorSeparator1";
this.bindingNavigatorSeparator1.Size = new System.Drawing.Size(6, 25);
//
// bindingNavigatorMoveNextItem
//
this.bindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorMoveNextItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveNextItem.Image")));
this.bindingNavigatorMoveNextItem.Name = "bindingNavigatorMoveNextItem";
this.bindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMoveNextItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorMoveNextItem.Text = "Move next";
//
// bindingNavigatorMoveLastItem
//
this.bindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorMoveLastItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveLastItem.Image")));
this.bindingNavigatorMoveLastItem.Name = "bindingNavigatorMoveLastItem";
this.bindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMoveLastItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorMoveLastItem.Text = "Move last";
//
// bindingNavigatorSeparator2
//
this.bindingNavigatorSeparator2.Name = "bindingNavigatorSeparator2";
this.bindingNavigatorSeparator2.Size = new System.Drawing.Size(6, 25);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
//
// toolStripLabel1
//
this.toolStripLabel1.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.toolStripLabel1.ForeColor = System.Drawing.SystemColors.HotTrack;
this.toolStripLabel1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripLabel1.Image")));
this.toolStripLabel1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripLabel1.Name = "toolStripLabel1";
this.toolStripLabel1.Size = new System.Drawing.Size(56, 22);
this.toolStripLabel1.Text = "Save";
this.toolStripLabel1.ToolTipText = "Save Record";
this.toolStripLabel1.Click += new System.EventHandler(this.toolStripLabel1_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Controls.Add(commentsLabel);
this.groupBox1.Controls.Add(this.commentsTextBox);
this.groupBox1.Controls.Add(this.comboBox5);
this.groupBox1.Controls.Add(fISShrtNameLabel);
this.groupBox1.Controls.Add(this.fISShrtNameTextBox);
this.groupBox1.Controls.Add(this.comboBox4);
this.groupBox1.Controls.Add(this.comboBox3);
this.groupBox1.Controls.Add(companyIDLabel);
this.groupBox1.Controls.Add(this.companyIDTextBox);
this.groupBox1.Controls.Add(nameLabel);
this.groupBox1.Controls.Add(this.nameTextBox);
this.groupBox1.Controls.Add(countryIDLabel);
this.groupBox1.Controls.Add(creditRateLabel);
this.groupBox1.Controls.Add(indIDLabel);
this.groupBox1.Location = new System.Drawing.Point(759, 92);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(445, 286);
this.groupBox1.TabIndex = 6;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Details";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(215, 176);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(22, 13);
this.label3.TabIndex = 28;
this.label3.Text = "<->";
//
// textBox1
//
this.textBox1.BackColor = System.Drawing.Color.Black;
this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox1.ForeColor = System.Drawing.Color.Lime;
this.textBox1.Location = new System.Drawing.Point(234, 172);
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(34, 22);
this.textBox1.TabIndex = 27;
this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// commentsTextBox
//
this.commentsTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.companyBindingSource, "Comments", true));
this.commentsTextBox.Location = new System.Drawing.Point(66, 198);
this.commentsTextBox.Name = "commentsTextBox";
this.commentsTextBox.Size = new System.Drawing.Size(331, 20);
this.commentsTextBox.TabIndex = 26;
//
// comboBox5
//
this.comboBox5.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.companyBindingSource, "CreditRate", true));
this.comboBox5.DataSource = this.CreditRatingbindingSource;
this.comboBox5.DisplayMember = "Name";
this.comboBox5.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox5.FormattingEnabled = true;
this.comboBox5.Location = new System.Drawing.Point(81, 172);
this.comboBox5.Name = "comboBox5";
this.comboBox5.Size = new System.Drawing.Size(132, 21);
this.comboBox5.TabIndex = 13;
this.comboBox5.ValueMember = "CompanyRatingID";
this.comboBox5.TextChanged += new System.EventHandler(this.comboBox5_TextChanged);
//
// CreditRatingbindingSource
//
this.CreditRatingbindingSource.DataMember = "CompanyCreditRatings";
this.CreditRatingbindingSource.DataSource = this.companyCreditRatingDataSet;
//
// companyCreditRatingDataSet
//
this.companyCreditRatingDataSet.DataSetName = "CompanyCreditRatingDataSet";
this.companyCreditRatingDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
//
// fISShrtNameTextBox
//
this.fISShrtNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.companyBindingSource, "FISShrtName", true));
this.fISShrtNameTextBox.Location = new System.Drawing.Point(88, 88);
this.fISShrtNameTextBox.Name = "fISShrtNameTextBox";
this.fISShrtNameTextBox.Size = new System.Drawing.Size(100, 20);
this.fISShrtNameTextBox.TabIndex = 12;
//
// comboBox4
//
this.comboBox4.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.companyBindingSource, "IndID", true));
this.comboBox4.DataSource = this.rEATIndustryDataSet;
this.comboBox4.DisplayMember = "Industry.Name";
this.comboBox4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox4.FormattingEnabled = true;
this.comboBox4.Location = new System.Drawing.Point(66, 144);
this.comboBox4.Name = "comboBox4";
this.comboBox4.Size = new System.Drawing.Size(147, 21);
this.comboBox4.TabIndex = 11;
this.comboBox4.ValueMember = "Industry.IndID";
//
// rEATIndustryDataSet
//
this.rEATIndustryDataSet.DataSetName = "REATIndustryDataSet";
this.rEATIndustryDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
//
// comboBox3
//
this.comboBox3.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.companyBindingSource, "CountryID", true));
this.comboBox3.DataSource = this.rEATCountryDataSet;
this.comboBox3.DisplayMember = "Country.Name";
this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox3.FormattingEnabled = true;
this.comboBox3.Location = new System.Drawing.Point(66, 117);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new System.Drawing.Size(147, 21);
this.comboBox3.TabIndex = 10;
this.comboBox3.ValueMember = "Country.CountryID";
//
// rEATCountryDataSet
//
this.rEATCountryDataSet.DataSetName = "REATCountryDataSet";
this.rEATCountryDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
//
// companyIDTextBox
//
this.companyIDTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.companyBindingSource, "CompanyID", true));
this.companyIDTextBox.Enabled = false;
this.companyIDTextBox.Location = new System.Drawing.Point(75, 30);
this.companyIDTextBox.Name = "companyIDTextBox";
this.companyIDTextBox.Size = new System.Drawing.Size(43, 20);
this.companyIDTextBox.TabIndex = 1;
//
// nameTextBox
//
this.nameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.companyBindingSource, "Name", true));
this.nameTextBox.Location = new System.Drawing.Point(48, 56);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(349, 20);
this.nameTextBox.TabIndex = 3;
//
// companyTableAdapter
//
this.companyTableAdapter.ClearBeforeFill = true;
//
// tableAdapterManager
//
this.tableAdapterManager.BackupDataSetBeforeUpdate = false;
this.tableAdapterManager.Company1TableAdapter = null;
this.tableAdapterManager.CompanyCreditRatingsTableAdapter = null;
this.tableAdapterManager.CompanyTableAdapter = this.companyTableAdapter;
this.tableAdapterManager.CountryTableAdapter = null;
this.tableAdapterManager.IndustryTableAdapter = null;
this.tableAdapterManager.UpdateOrder = REAT.REATCompanyDataSetTableAdapters.TableAdapterManager.UpdateOrderOption.InsertUpdateDelete;
//
// CountrybindingSource
//
this.CountrybindingSource.DataMember = "Country";
this.CountrybindingSource.DataSource = this.rEATCountryDataSet;
//
// countryTableAdapter
//
this.countryTableAdapter.ClearBeforeFill = true;
//
// IndustrybindingSource
//
this.IndustrybindingSource.DataMember = "Industry";
this.IndustrybindingSource.DataSource = this.rEATIndustryDataSet;
//
// industryTableAdapter
//
this.industryTableAdapter.ClearBeforeFill = true;
//
// panel2
//
this.panel2.Controls.Add(this.dataGridView1);
this.panel2.Location = new System.Drawing.Point(12, 80);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(731, 230);
this.panel2.TabIndex = 7;
//
// dataGridView1
//
this.dataGridView1.AutoGenerateColumns = false;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.companyIDDataGridViewTextBoxColumn,
this.nameDataGridViewTextBoxColumn,
this.fISShrtNameDataGridViewTextBoxColumn,
this.countryIDDataGridViewTextBoxColumn,
this.indIDDataGridViewTextBoxColumn,
this.creditRateDataGridViewTextBoxColumn,
this.Comments});
this.dataGridView1.DataSource = this.companyBindingSource;
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(0, 0);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.ReadOnly = true;
this.dataGridView1.Size = new System.Drawing.Size(731, 230);
this.dataGridView1.TabIndex = 0;
//
// companyIDDataGridViewTextBoxColumn
//
this.companyIDDataGridViewTextBoxColumn.DataPropertyName = "CompanyID";
this.companyIDDataGridViewTextBoxColumn.HeaderText = "CompanyID";
this.companyIDDataGridViewTextBoxColumn.Name = "companyIDDataGridViewTextBoxColumn";
this.companyIDDataGridViewTextBoxColumn.ReadOnly = true;
this.companyIDDataGridViewTextBoxColumn.Width = 110;
//
// nameDataGridViewTextBoxColumn
//
this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name";
this.nameDataGridViewTextBoxColumn.HeaderText = "Name";
this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn";
this.nameDataGridViewTextBoxColumn.ReadOnly = true;
this.nameDataGridViewTextBoxColumn.Width = 250;
//
// fISShrtNameDataGridViewTextBoxColumn
//
this.fISShrtNameDataGridViewTextBoxColumn.DataPropertyName = "FISShrtName";
this.fISShrtNameDataGridViewTextBoxColumn.HeaderText = "FISShrtName";
this.fISShrtNameDataGridViewTextBoxColumn.Name = "fISShrtNameDataGridViewTextBoxColumn";
this.fISShrtNameDataGridViewTextBoxColumn.ReadOnly = true;
//
// countryIDDataGridViewTextBoxColumn
//
this.countryIDDataGridViewTextBoxColumn.DataPropertyName = "CountryID";
this.countryIDDataGridViewTextBoxColumn.HeaderText = "CountryID";
this.countryIDDataGridViewTextBoxColumn.Name = "countryIDDataGridViewTextBoxColumn";
this.countryIDDataGridViewTextBoxColumn.ReadOnly = true;
this.countryIDDataGridViewTextBoxColumn.Width = 50;
//
// indIDDataGridViewTextBoxColumn
//
this.indIDDataGridViewTextBoxColumn.DataPropertyName = "IndID";
this.indIDDataGridViewTextBoxColumn.HeaderText = "IndID";
this.indIDDataGridViewTextBoxColumn.Name = "indIDDataGridViewTextBoxColumn";
this.indIDDataGridViewTextBoxColumn.ReadOnly = true;
//
// creditRateDataGridViewTextBoxColumn
//
this.creditRateDataGridViewTextBoxColumn.DataPropertyName = "CreditRate";
this.creditRateDataGridViewTextBoxColumn.HeaderText = "CreditRating";
this.creditRateDataGridViewTextBoxColumn.Name = "creditRateDataGridViewTextBoxColumn";
this.creditRateDataGridViewTextBoxColumn.ReadOnly = true;
//
// Comments
//
this.Comments.DataPropertyName = "Comments";
this.Comments.HeaderText = "Comments";
this.Comments.Name = "Comments";
this.Comments.ReadOnly = true;
//
// companyCreditRatingsTableAdapter
//
this.companyCreditRatingsTableAdapter.ClearBeforeFill = true;
//
// Company1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1214, 378);
this.Controls.Add(this.panel2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.panel1);
this.Name = "Company1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Company";
this.Activated += new System.EventHandler(this.Company1_Activated);
this.Deactivate += new System.EventHandler(this.Company1_Deactivate);
this.Load += new System.EventHandler(this.Company1_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.companyBindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.rEATCompanyDataSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingNavigator1)).EndInit();
this.bindingNavigator1.ResumeLayout(false);
this.bindingNavigator1.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.CreditRatingbindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.companyCreditRatingDataSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.rEATIndustryDataSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.rEATCountryDataSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.CountrybindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.IndustrybindingSource)).EndInit();
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
}
VulpesRank #55 · 29.2K reputationPosted Aug 5, 2014, 12:19 PM EDT
I've looked at every line which involves comboBox5 or textBox1 and can't find anything untoward at all!
So I doubt whether deleting those controls and adding them back again would be likely to solve the problem.
My only other suggestion would be to handle the FormClosing event and put a MessageBox.Show in there to see if the first click of the close button does in fact get through.
But, unless Sumit has any other ideas, it's beginning to look like you'll just have to live with the problem :(
Guest UserRank #259 · 9.8K reputationPosted Aug 5, 2014, 10:27 PM EDT
If you can share your code base, so please upload the solution, so I can open in our Visual Studio and try at my end?
thnx
Mario Cuervo26 reputationPosted Aug 6, 2014, 9:31 AM EDT
VulpesRank #55 · 29.2K reputationPosted Aug 6, 2014, 11:31 AM EDT
I wasn't expecting that - I thought the first click of the X button would just get swallowed.
Anyway, it does gives us the opportunity for some remedial action even if we don't know what's causing it.
One possibility is that e.Cancel (where 'e' is the FormClosingEventArgs argument) is being set to true by the system even though it's default value should be false.
So, I'd see if putting this line in the event handler solves the problem:
if (e.Cancel) e.Cancel = false;
If it's no better but Company1 is your start up form, then try instead:
Environment.Exit(1);
In theory this should kill the process stone dead before the FormClosing event fires again. The gentler, Application.Exit(), won't work here because it'll cause the FormClosing event to fire yet again.
If Company1 isn't your start up form and you don't therefore want to kill the process, we could do a little more digging with:
MessageBox.Show(e.CloseReason.ToString());
Mario Cuervo26 reputationPosted Aug 8, 2014, 9:54 AM EDT
Mario Cuervo26 reputationPosted Aug 8, 2014, 9:57 AM EDT
Mario Cuervo26 reputationPosted Aug 11, 2014, 10:50 AM EDT
Thanks for your suggestion:
the statement: comboBox5.SelectedIndexChanged -= comboBox5_SelectedIndexChanged; does not compile, maybe a syntax error, however your idea of using DestroyWindow solves the problem without any secondary effect .... so far.
Thanks again!