说真的C#的DataGridView中的功能虽然强大!但是对这些自带的XXXColumn 支持的功能还是不够的!这篇就备忘下怎么让DataGridViewButtonColumn 支持灰掉,也就是不支持人家点啦!
就是下面这种。
这种需求还是很多的!既然不支持,没事,自己封装好了!
1. 来。上代码!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Windows.Forms.VisualStyles;
namespace UI
{
public class CustomDGVButtonCell : DataGridViewButtonCell
{
public bool Enabled { get; set; }
// By default, enable the button cell.
public CustomDGVButtonCell()
{
Enabled = true;
}
// Override the Clone method so that the Enabled property is