日期:2014-05-20 浏览次数:21035 次
public partial class Fittings : Form
{
private int ProductsID = 120;
public Fittings()
{
InitializeComponent();
}
private void Fittings_Load(object sender, EventArgs e)
{
dgvFittingsList.AutoGenerateColumns = false;
getFittingsList(ProductsID);
dgvFittingsList.ClearSelection();//无效
dgvFittingsList.CurrentCell = null;//无效
dgvFittingsList.Rows[0].Selected = false;//无效
}
/// <summary>
/// 根据产品ID读取配件数据
/// </summary>
/// <param name="ProductID">产品ID</param>
private void getFittingsList(int ProductID)
{
DataSet ds = new DataSet();
ds = BLL.Fittings.Fittings.getFittings(ProductID);
dgvFittingsList.DataSource = ds.Tables[0];
dgvFittingsList.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGray;//奇数行背景色
}
private void dgvFittingsList_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (dgvFittingsList.Columns[e.ColumnIndex].Name.Equals("是否原装"))//重定义"是否原装"列的值
{
e.FormattingApplied = true;
DataGridViewRow row = dgvFittingsList.Rows[e.RowIndex];
string strValue = row.Cells["是否原装"].Value.ToString();
switch (strValue)