pls give us a Api likes Virtual CellPaint in DataGridViewTextBoxCell
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 1.1k
- Avg merge
- 20h 23m
- Merged PRs (30d)
- 103
Description
### Is your feature request related to a problem? Please describe
The underlying area rendering and calculation of DataGridViewTextBoxCell is a very complicated process. It is difficult to simulate the built-in algorithm by modifying the Paint method to realize the position size, Margin, Padding layout, etc. This will break the unified appearance. But if winform pre-set By leaving a CellPaint method, the user has a way to intercept the data presented to the render before the final render to make fine-tuning.
Example:
When certain properties are set to the DataGridView.
Developers cannot control the cell to affect text rendering by modifying style or formatting props. Not even Paint.
A typical example is that DataGridView.RightToLeft is set to: RightToLeft.Yes. All cells of the entire DataGridView become RightToLeft. However, only some columns are required, which is the majority of cases. I think the cost of completely modifying the underlying code of DataGridView It is very expensive, but adding a CellPaint as described below is a very low-cost, non-destructive, and highly forward-compatible solution.
example see the screenshot. more detial see https://github.com/dotnet/winforms/issues/8898#issuecomment-1491239893

### Describe the solution you'd like and alternatives you've considered
this is the line in PaintPrivate
https://github.com/dotnet/winforms/blob/f777662b7d00d81e52255e3c3b699f401eaaea6c/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxCell.cs#L737
wapper it as CellPaint
```C#
protected virtual void CellPaint(Graphics graphics,
Rectangle valBounds,
string formattedString,
DataGridViewCellStyle cellStyle,
bool cellSelected,
TextFormatFlags flags)
{
TextRenderer.DrawText(graphics,
formattedString,
cellStyle.Font,
valBounds,
cellSelected ? cellStyle.SelectionForeColor : cellStyle.ForeColor,
flags);
}
```
// Calling in line of PaintPrivate
https://github.com/dotnet/winforms/blob/f777662b7d00d81e52255e3c3b699f401eaaea6c/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxCell.cs#L737
```C#
CellPaint(graphics,
formattedString,
cellStyle.Font,
valBounds,
cellSelected ? cellStyle.SelectionForeColor : cellStyle.ForeColor,
flags);
```
my alternatives is:
```C#
//use https://github.com/pardeike/Harmony/ to modify PaintPrivate at runtime
//direct copy the PaintPrivate code in my code and override the Paint method.
```
but these ways are hard to do.
### Will this feature affect UI controls?
no effects
Contributor guide
Assessment
This issue has not been assessed yet.