Datagridview Font When editing cell

Jeff Gaines 251 Reputation points
2023-01-27T16:02:10.4366667+00:00

I have not used the Datagridview before so have started a test Windows Forms app to learn about it. I notice that when I edit a cell the font size changes to something too small to read, is there a way to prevent this?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,370 questions
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 48,046 Reputation points
    2023-01-27T16:27:08.46+00:00

    The styling of a cell is determined by the DefaultCellStyle property of the grid. After this style then other styles get applied based upon the column, row and selection state.

    When the user edits a cell then it actually switches to the cell editing control. That control inherits the styling of the grid but it may have additional styling. If you need to customize the edit control then you'd need to handle the EditingControlShowing event and then you can grab the underlying edit control being used.

    But, without seeing an example, I wonder if the issue is just that the cell size isn't big enough for the edit control (since it'll require more space than the unedited text) and scaling is kicking in to make it smaller. Try making your cell a little bigger if possible and see if the issue goes away. If it doesn't then please post a code sample demoing the problem for us.


0 additional answers

Sort by: Most helpful