Hi guys,
I’m trying to do something along the lines of this thread,
https://wisej.com/support/question/how-do-i-add-a-custom-control-to-a-data-grid-view
However, the samples in the answers do not work anymore in 3.2.1 (the question is since 2018). In particular, in the overriden SetValue I get a null exception at the point indicated in the following snipet.
If I remove the SetValue altogether, to get around the problem, the cells of the relevant column show up empty. It looks like somehow this.Control is reset to null.
What is the updated version for this?
Best,
Alex
public class DatagridViewProgressBarCell : DataGridViewCell
{
public DatagridViewProgressBarCell()
{
this.Control = new ProgressBar() {
Dock = DockStyle.Fill
};
}
protected override bool SetValue(object value)
{
((ProgressBar)this.Control).Value = (int)value; // <<==== this.Control is null
return base.SetValue(value);
}
}
Hi Alex,
I have attached a sample to steer you in the right direction!.
It’s not a bug per se, but it is an enhancement that will be included in a future release!
Basically, you’ll need to override the Clone() method of the DataGridViewCell and assign your control there!
HTH,
Alaa
Hi Alex,
I could reproduce what you reported and we´ll check in detail what changed here.
We´ll get back to you asap.
Best regards
Frank
Please login first to submit.