c# DataGridView Seçili Satırın Fontunu, Rengini Değiştirme
DataGridView Seçili Satırın Fontunu, Rengini Değiştirme
Merhaba arkadaşlar. Bu makalemizde seçili satırın arkaplan rengini ve fontunu değiştireceğiz.
[cc lang=”c#”]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
dataGridView1.CellFormatting += newDataGridViewCellFormattingEventHandler(dataGridView1_CellFormatting);
}
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (dataGridView1.Rows[e.RowIndex].Selected)
{
//seçli satırı kalın yapıyoruz.
e.CellStyle.Font = new Font(“Arial”, 12, FontStyle.Bold);
//seçli satırın backcolor rengini kırmızı yapıyoruz.
e.CellStyle.SelectionBackColor = Color.Red;
//seçili satır yazı rengini beyaz yapıyoruz
e.CellStyle.SelectionForeColor = Color.White;
}
}
}
}
[/cc]Kaynak : http://www.bahadirsam.somee.com/sayfaindeks.aspx