How to "ownerdraw" a textbox


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Thanks! I'll look into this.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
One other thought....you may want to use the TextBoxRenderer class to help you generate the standard background, etc instead of manually reinventing the wheel.  You can have it draw the standard background to a device context (graphics) so this way you can just render what the text and what you want to add.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Inherit a textbox, the in the constructor call the SetStyle method:

SetStyle(UserPaint, True)

When you do this, you can then override the OnPaint method and get to rendering:

Protected Overrides Sub OnPaint(...)
   '-- e.Graphics.GetToRendering
End Sub

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'd like to have a TextBox with a button beside it (it will "zoom" in on the contents by opening another form). However, as you know, there is no OwnerDraw for text boxes (at least I couldn't find it). I attempted a UserControl, that that was waaaaay too much work and a bit wanky to boot because I need a TextBox in all its glory, plus a something clickable right beside it.



To recap: I want a SF TextBox with some clickable element beside it (maybe a label with an image or a button). I'd like this to be a single control that I drop on the form, rather than two (I use this a lot).



So, any ideas on how I might do this?



Thanks!
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search