StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



How to "ownerdraw" a textboxExpand / Collapse
Author
Message
Posted 02/08/2008 10:50:32 AM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Yesterday @ 10:03:03 PM
Posts: 1,322, Visits: 3,439
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!
Post #14203
Posted 02/08/2008 11:08:07 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 3:20:54 PM
Posts: 4,769, Visits: 4,731
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
Post #14206
Posted 02/08/2008 11:31:48 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 3:20:54 PM
Posts: 4,769, Visits: 4,731
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.
Post #14207
Posted 02/08/2008 11:41:59 AM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Yesterday @ 10:03:03 PM
Posts: 1,322, Visits: 3,439
Thanks! I'll look into this.
Post #14208
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 6:08am

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.063. 11 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.