Letter spacing in winforms Textbox c#.

ankit goel 40 Reputation points
2025-08-01T16:43:06.0066667+00:00

Hi ,

i am using c# winforms 2022 community . WPF or any other technology is not an option . I am trying to reduce the character spacing inside the textbox such that if the characters length exceeds the width of the textbox , it should automatically reduce the character spacing in the text written .
for example in the below pic , 34 characters can be seen fitting easily in a textbox
User's image

but when i exceed the characters inside it , they reduces their character spacing between them .
User's image

i know this looks ugly but this is due to the screenshot taken by magnifier app . I am open to using custom or other controls which can behave like textbox and make my work .

Developer technologies | Windows Forms
{count} votes

Answer accepted by question author
  1. Bruce (SqlWork.com) 81,976 Reputation points Volunteer Moderator
    2025-08-01T18:21:43.9433333+00:00

    As you need control of the character kerning based on width, you will need write a custom control. See:

    https://learn.microsoft.com/en-us/dotnet/desktop/winforms/controls-design/overview

    to draw the text you will need gdi drawing

    https://learn.microsoft.com/en-us/windows/win32/gdi/drawing-text

    0 comments No comments

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.