Share via

Datagridview Font When editing cell

Jeff Gaines 371 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?

Developer technologies | .NET | Other
0 comments No comments

Answer accepted by question author

Michael Taylor 61,221 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.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.