2017-05-18 27 views
0

我正在Visual Studio中開發一個C#項目。我必須在DataGridView中使用複選框Like this Image, 但是這個複選框非常小。 我在互聯網上搜索很多,但沒有得到滿意的答案。 有沒有解決方案或框架?在C#中的#DataGridView中增加複選框的大小

+3

你看看這個鏈接'HTTP:// stackoverflow.com /問題/ 36171250 /如何對變化複選框 - 大小 - 中 - datagridviewcheckboxcell' –

+1

但我認爲它足夠大 –

+0

是否有任何建議 –

回答

0

解決方案是...

private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) 
    { 
     if (e.ColumnIndex == 1 && e.RowIndex >= 0) 
     { 
      e.PaintBackground(e.CellBounds, true); 
      ControlPaint.DrawCheckBox(e.Graphics, e.CellBounds.X + 1, e.CellBounds.Y + 1, 
       e.CellBounds.Width - 2, e.CellBounds.Height - 2, 
       (bool) e.FormattedValue ? ButtonState.Checked : ButtonState.Normal); 
      e.Handled = true; 
     }