I have a C # UserControl that hosts a TextBox.
When the user control is disabled, I would like the TextBox to appear as if it was disabled + ReadOnly (i.e. not grayed out). Therefore, when a user control catches EnabledChanged, it sets the placed TextBox properties appropriately.
However, the Enabled state with UserControl takes precedence over everything else, and the TextBox is still grayed out (although its internal ForeColor is correct).
So I decided to hide the hosted TextBox when the user control was disabled and drew it myself. I can successfully display the TextBox frame using various ControlPaint.DrawXxx functions.
However, when you draw text, you get a stretched output compared to your own rendering. That is, the text starts at the same pixel location, but the distance between the characters is noticeably greater.
I use my own TextBox font to render, so I don't know what I'm doing wrong. The only excuse I can make is that the C # TextBox is displayed directly by Windows (using the ExtTextOut Win32 API), and this leads to obvious differences.
What options can I use to simulate TextBox's own rendering?
source share