I have a windows form and having datagridview which binds to dataset dynamically , now in the form on the button click event I am changing the datagridview font appearance . I tried below code but its not effecting on Datagridview , only header part is being changing . Please recommended what I done wrong in coding.
My Code
private void Btn_Language_Click(object sender, EventArgs e) { if(DGV_View.Font.Name == "Trebuchet MS") { DGV_View.Font = new System.Drawing.Font("NILKANTH", 12); this.DGV_View.DefaultCellStyle.Font = new System.Drawing.Font("NILKANTH", 12); } else if(DGV_View.Font.Name == "NILKANTH") { DGV_View.Font = new System.Drawing.Font("Trebuchet MS", 11); } }
Amit Kumar SinghPosted Dec 8, 2016, 12:11 AM
You need to First get The RowIndex
then Column Index and Then Set Font of Cell :)
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
//Get Row Index
int Rowindex = e.RowIndex;
//Get Column Index
int CellIndex = e.ColumnIndex;
//Set Font to Bold
dataGridView1.Rows[Rowindex].Cells[CellIndex].Style.Font = newFont("Arial",12,FontStyle.Bold);
}
Use below if you want to set Whole Row Font to Bold
dataGridView1.Rows[Rowindex].DefaultCellStyle.Font = new Font("Arial", 12, FontStyle.Bold);
Mamta JainPosted Dec 8, 2016, 12:04 AM
Salman BegPosted Dec 7, 2016, 11:58 PM
Hi.You Should implement like this,thanksSreekanth ReddyPosted Dec 7, 2016, 11:54 PM