3C科技 娛樂遊戲 美食旅遊 時尚美妝 親子育兒 生活休閒 金融理財 健康運動 寰宇綜合

Zi 字媒體

2017-07-25T20:27:27+00:00
加入好友
C# datagridview 文字顏色 資料來源: https://docs.microsoft.com/zh-tw/dotnet/desktop/winforms/controls/how-to-set-font-and-color-styles-in-the-windows-forms-datagridview-control?view=netframeworkdesktop-4.8 https://bbs.csdn.net/topics/270042463 01.指定 DataGridView 儲存格所使用的字型 this.dataGridView1.DefaultCellStyle.Font = new Font("Tahoma", 15); 02.指定 DataGridView 儲存格的前景和背景色彩 this.dataGridView1.DefaultCellStyle.ForeColor = Color.Blue; this.dataGridView1.DefaultCellStyle.BackColor = Color.Beige; 03.指定所選取 DataGridView 儲存格的前景和背景色彩 this.dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Yellow; this.dataGridView1.DefaultCellStyle.SelectionBackColor = Color.Black; 範例 private void SetFontAndColors() { this.dataGridView1.DefaultCellStyle.Font = new Font("Tahoma", 15); this.dataGridView1.DefaultCellStyle.ForeColor = Color.Blue; this.dataGridView1.DefaultCellStyle.BackColor = Color.Beige; this.dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Yellow; this.dataGridView1.DefaultCellStyle.SelectionBackColor = Color.Black; } dataGridView1.Rows[i].DefaultCellStyle.ForeColor = Color.Red; dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Blue;

本文由jashliaoeuwordpress提供 原文連結

寫了 5860316篇文章,獲得 23313次喜歡
精彩推薦