PDA

View Full Version : تغییر رنگ یکی در میان سطرهای گرید ویو



saeedhushmand
چهارشنبه 18 آبان 1390, 12:02 عصر
من یه combobox دارم که توش یک item با نام زرد دارم می خوام وقتی کسی روی زرد کلیک کرد سطرهای گرید ویو یکی در میان به رنگ زرد در بیاد

zare69
چهارشنبه 18 آبان 1390, 14:46 عصر
سلام فکر کنم این کد به دردت بخوره.

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex==0)
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
dataGridViewCellStyle3.BackColor = System.Drawing.Color.Yellow;
this.dataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3;
}
if (comboBox1.SelectedIndex == 1)
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
dataGridViewCellStyle3.BackColor = System.Drawing.Color.Red;
this.dataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3;
}
if (comboBox1.SelectedIndex == 2)
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
dataGridViewCellStyle3.BackColor = System.Drawing.Color.Green;
this.dataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3;
}
}

saeedhushmand
چهارشنبه 18 آبان 1390, 15:58 عصر
ممنون درست بود...