I compare the code to another form and its the same. The code for
System.ComponetModel.Component is set to Null, just like my other forms.
private System.ComponentModel.Container components = null;
Here is all the code of the form. I replaced the password for security.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace LicenseDealerSales
{
/// <summary>
/// Summary description for frmDealerSearch.
/// </summary>
///
public class frmDealerSearch : System.Windows.Forms.Form
{
private System.Windows.Forms.Button cmdOk;
private System.Windows.Forms.Button cmdCancel;
private System.Windows.Forms.DataGrid dgDealerInfo;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public frmDealerSearch()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(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()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(frmDealerS earch));
this.cmdOk = new System.Windows.Forms.Button();
this.cmdCancel = new System.Windows.Forms.Button();
this.dgDealerInfo = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.d gDealerInfo)).BeginInit();
this.SuspendLayout();
//
// cmdOk
//
this.cmdOk.Location = new System.Drawing.Point(152, 152);
this.cmdOk.Name = "cmdOk";
this.cmdOk.Size = new System.Drawing.Size(112, 40);
this.cmdOk.TabIndex = 1;
this.cmdOk.Text = "&OK";
this.cmdOk.Click += new System.EventHandler(this.cmdOk_Click);
//
// cmdCancel
//
this.cmdCancel.Location = new System.Drawing.Point(336, 152);
this.cmdCancel.Name = "cmdCancel";
this.cmdCancel.Size = new System.Drawing.Size(112, 40);
this.cmdCancel.TabIndex = 2;
this.cmdCancel.Text = "&Cancel";
this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click);
//
// dgDealerInfo
//
this.dgDealerInfo.Anchor =
((System.Windows.Forms.AnchorStyles)((((System.Win dows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgDealerInfo.DataMember = "";
this.dgDealerInfo.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dgDealerInfo.Location = new System.Drawing.Point(16, 16);
this.dgDealerInfo.Name = "dgDealerInfo";
this.dgDealerInfo.ReadOnly = true;
this.dgDealerInfo.Size = new System.Drawing.Size(576, 112);
this.dgDealerInfo.TabIndex = 0;
//
// frmDealerSearch
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 13);
this.BackColor = System.Drawing.Color.LightSteelBlue;
this.ClientSize = new System.Drawing.Size(610, 216);
this.ControlBox = false;
this.Controls.Add(this.cmdOk);
this.Controls.Add(this.cmdCancel);
this.Controls.Add(this.dgDealerInfo);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this. Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmDealerSearch";
this.Text = "Dealer Search";
this.Load += new System.EventHandler(this.frmDealerSearch_Load);
((System.ComponentModel.ISupportInitialize)(this.d gDealerInfo)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void cmdCancel_Click(object sender, System.EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private void cmdOk_Click(object sender, System.EventArgs e)
{
frmDataEntry f = new frmDataEntry();
f.SetTextBox("Test");
this.DialogResult = DialogResult.OK;
}
private void frmDealerSearch_Load(object sender, System.EventArgs e)
{
string sConnString = "Data Source=db;Database=License;Integrated
Security=False;User ID=sa;password=password";
string sProc = "prGet_DealerInfo";
using (SqlConnection oCn = new SqlConnection(sConnString))
{
using (SqlCommand oCmd = new SqlCommand(sProc, oCn))
{
oCn.Open();
oCmd.CommandType = CommandType.StoredProcedure;
oCmd.Parameters.Add("@sDealerNum", SqlDbType.NChar, 6);
oCmd.Parameters["@sDealerNum"].Value = "101043";
SqlDataAdapter oDa = new SqlDataAdapter();
oDa.SelectCommand = oCmd;
DataSet ds=new DataSet();
oDa.Fill(ds);
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName="DealerInfo";
int numCols = ds.Tables[0].Columns.Count;
DataGridNoActiveCellColumn aColumnTextColumn ;
for(int i = 0; i < numCols; ++i)
{
aColumnTextColumn = new DataGridNoActiveCellColumn();
aColumnTextColumn.HeaderText = ds.Tables[0].Columns[i].ColumnName;
aColumnTextColumn.MappingName = ds.Tables[0].Columns[i].ColumnName;
tableStyle.GridColumnStyles.Add(aColumnTextColumn) ;
}
dgDealerInfo.TableStyles.Clear();
tableStyle.MappingName=ds.Tables[0].TableName;
dgDealerInfo.TableStyles.Add(tableStyle);
dgDealerInfo.DataSource = ds.Tables[0];
}
}
}
}
public class DataGridNoActiveCellColumn : DataGridTextBoxColumn
{
private int SelectedRow = -1;
protected override void Edit(System.Windows.Forms.CurrencyManager source,
int rowNum, System.Drawing.Rectangle bounds, bool readOnly,string
instantText,bool cellIsVisible)
{
//make sure previous selection is valid
if(SelectedRow > -1 && SelectedRow < source.List.Count + 1)
this.DataGridTableStyle.DataGrid.UnSelect(Selected Row);
SelectedRow = rowNum;
this.DataGridTableStyle.DataGrid.Select(SelectedRo w);
}
}
}
"Kevin Yu [MSFT]" wrote:
Hi Cadel,
This icon is used when the file is a Component Class or a Windows Service.
Please check what class is this class inherited from in the .cs file. A
component is inherited from System.ComponentModel.Component.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."