【问题标题】:Increase the size of Checkbox in #DataGridView in C#在C#中增加#DataGridView中Checkbox的大小
【发布时间】:2017-05-19 14:48:19
【问题描述】:

我正在 Visual Studio 中开发一个 C# 项目。我必须使用 DataGridView 中的 checkboxLike this Image, 但是这个复选框非常小。 我在互联网上搜索了很多,但没有得到满意的答案。 有没有解决方案或框架?

【问题讨论】:

  • 你看看这个链接http://stackoverflow.com/questions/36171250/how-to-change-checkbox-size-in-datagridviewcheckboxcell
  • 但我觉得够大了
  • 还有什么建议
  • 由于复选框既不是 C# 的一部分,也不是 VS 的一部分,所以值得一提的是,您使用的是哪个 UI 框架(WinForms、WPF)...
  • 我正在使用 Winforms.. 非常感谢.. 我得到了答案..

标签: c# visual-studio checkbox datagridview


【解决方案1】:

解决方案是..

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;
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-02
    • 2017-03-02
    • 2014-02-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多