TextBox with custom OnPaint

G

Guest

I am trying to write a TextBox control (C#) which displays text which is the
exact Height of the text box (No space above and below) This control would
support uppercase characters only (ones that do no drop below the baseline)

The CF seems to automaticallty adjust the Height of the TextBox when the
Font is set and this automatically includes space above and below the text.
The PreferredHeight property is not supported by Compact Framework.

I have tried to create a TextBox derived class which can override OnPaint.
This does not seem to be possible because any call to GetGraphics from with
the TextBox code, throws an exception.

Secondly I tried to write my own TextBox class derived directly from Control
(instead of TextBox or TextBox base). In this case I can implement OnPaint,
but it is unacceptable becuase I can not accurately place the caret. When I
attempt to place the caret, I use MeasureString, but this does not seem to
measure accurately enough to place the caret exactly where it belongs. (It is
always a little to far to the right)

Aside from my problem with the caret my control works as I would like.

Any ideas on how this can be accomplished?? Has anyone written such a
TextBox with CF 2.0?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top