Solution Explorer

G

Guest

This is a Winform.

One of my Winform icons is different than the rest displayed in the Solution
Explorer. Most of the form icon are small icon form with two text boxes and
two labels in front of the text boxes. But the odd icon, has three squares,
green square then a blue square then a red square on top of the blue square.

Why is this icon different for this win form? I went through all the
properties, same as the other forms.
 
K

Kevin Yu [MSFT]

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."
 
G

Guest

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(frmDealerSearch));
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.dgDealerInfo)).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.Windows.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.dgDealerInfo)).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.ColumnName;

aColumnTextColumn.MappingName = ds.Tables[0].Columns.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(SelectedRow);
SelectedRow = rowNum;
this.DataGridTableStyle.DataGrid.Select(SelectedRow);
}
}
}
 
K

Kevin Yu [MSFT]

Hi Cadel,

Thanks for posting your code here. I tried your code on my machine, and I
was able to reproduce it.

Based on the code you have provided, I found that another class public
class DataGridNoActiveCellColumn : DataGridTextBoxColumn is defined in the
cs file. This is why the icon changed. VS.NET regard it as a component
because not only the form class is defined. This is by design. If you put
the public class DataGridNoActiveCellColumn : DataGridTextBoxColumn class
definition to another file, the icon changes back to form icon.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top